-
Notifications
You must be signed in to change notification settings - Fork 9
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
Resolve relative paths to source projects #8
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,9 @@ var style = function(uri, callback) { | |
// override properties if necessary | ||
data.scale = +uri.query.scale || data.scale; | ||
|
||
// Resolve relative path to data source | ||
data.source = resolveTileliveUri(uri, url.parse(data.source)); | ||
|
||
return style.toXML(data, function(err, xml) { | ||
if (err) { | ||
return callback(err); | ||
|
@@ -225,6 +228,17 @@ style.registerProtocols = function(tilelive) { | |
tilelive.protocols["tmstyle:"] = this; | ||
}; | ||
|
||
function resolveTileliveUri(fromUri, toUri) { | ||
// Normalize uris | ||
fromUri = url.parse(fromUri); | ||
toUri = url.parse(toUri); | ||
|
||
// Url.parse reads the first ".." as the hostname | ||
const toUriPathName = path.join(toUri.hostname, toUri.path); | ||
|
||
return toUri.protocol + '//' + path.resolve(fromUri.pathname, toUriPathName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only appropriate for sources that read from the filesystem. In many cases, the protocol may be Off the top of my head, appropriate protocols are https://github.com/mojodna/tilelive-modules/blob/master/index.json contains a mostly complete list of modules to refer to. |
||
} | ||
|
||
module.exports = function(_tilelive, options) { | ||
tilelive = _tilelive; | ||
|
||
|
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.
fromUri
should get the same treatment.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.
fixed