Skip to content

Commit

Permalink
Don't use the static Uri.resolve method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jan 30, 2014
1 parent 802d116 commit f814953
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Source/Scene/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ define([
return;
}

var baseUri = new Uri(metadataUrl);

that._tileUrlTemplates = data.tiles;
for (var i = 0; i < that._tileUrlTemplates.length; ++i) {
that._tileUrlTemplates[i] = Uri.resolve(that._tileUrlTemplates[i], metadataUrl).replace('{version}', data.version);
that._tileUrlTemplates[i] = new Uri(that._tileUrlTemplates[i]).resolve(baseUri).toString().replace('{version}', data.version);
}

that._availableTiles = data.available;
Expand Down
25 changes: 13 additions & 12 deletions Source/ThirdParty/Uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,20 @@ define(function() {
this.path = output.join('/');
};

/**
* Resolves a relative URI against an absolute base URI.
* Convenience method.
* @param {String} uri the relative URI to resolve
* @param {String} baseURI the base URI (must be absolute) to resolve against
*/
URI.resolve = function(sURI, sBaseURI) {
var uri = cache[sURI] || (cache[sURI] = new URI(sURI));
var baseURI = cache[sBaseURI] || (cache[sBaseURI] = new URI(sBaseURI));
return uri.resolve(baseURI).toString();
};
// We don't like this function because it builds up a cache that is never cleared.
// /**
// * Resolves a relative URI against an absolute base URI.
// * Convenience method.
// * @param {String} uri the relative URI to resolve
// * @param {String} baseURI the base URI (must be absolute) to resolve against
// */
// URI.resolve = function(sURI, sBaseURI) {
// var uri = cache[sURI] || (cache[sURI] = new URI(sURI));
// var baseURI = cache[sBaseURI] || (cache[sBaseURI] = new URI(sBaseURI));
// return uri.resolve(baseURI).toString();
// };

var cache = {};
// var cache = {};

/**
* Serialises the URI to a string.
Expand Down

0 comments on commit f814953

Please sign in to comment.