-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure baseURL are absolute when printing #270
Conversation
@@ -271,7 +271,7 @@ ngeo.Print.prototype.encodeWmsLayer_ = function(arr, opacity, url, params) { | |||
goog.object.remove(customParams, 'FORMAT'); | |||
|
|||
var object = /** @type {MapFishPrintWmsLayer} */ ({ | |||
baseURL: url, | |||
baseURL: url.match(/^https?:/) ? url : 'http:' + url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assume that, if url
doesn't start with http
or https
it will start with //
. That doesn't sound correct to me. What if url
looks like path/to/wms
or /path/to/wms
?
GeoExt's print provider includes a getAbsoluteUrl
function that we could copy to ngeo. The function would be simpler in ngeo as we don't need to support IE < 9.
PR updated: I now use the getAbsuloteUrl from geoExt. |
* @param {string} url | ||
* @return {string} Absolute URL. | ||
*/ | ||
ngeo.Print.prototype.getAbsoluteUrl_ = function(url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make this function static: ngeo.Print.getAbsolute_
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And do not forget the @private
annotation.
PR update:
|
@@ -252,14 +252,16 @@ ngeo.Print.prototype.encodeImageWmsLayer_ = function(arr, layer) { | |||
|
|||
var url = source.getUrl(); | |||
var params = source.getParams(); | |||
this.encodeWmsLayer_(arr, layer.getOpacity(), url, params); | |||
if (goog.isDefAndNotNull(url)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use if (goog.isDef(url))
here no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so yes. Is it problematic to use goog.isDefAndNotNull(url)
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more processing. It's confusing for readers of the code, who may think that source.getUrl()
may return null
. I've become strict with typing, and I think it's right :)
This PR's branch needs to be rebased. |
- Import the getAbsolute function from GeoExt - Drop compatibility for IE < 9
|
Make sure baseURL are absolute when printing
Thanks. |
No description provided.