diff --git a/Source/Scene/BingMapsImageryProvider.js b/Source/Scene/BingMapsImageryProvider.js index 60ad26db310a..6e31778486bd 100644 --- a/Source/Scene/BingMapsImageryProvider.js +++ b/Source/Scene/BingMapsImageryProvider.js @@ -106,6 +106,7 @@ define([ this._key = BingMapsApi.getKey(options.key); this._resource = Resource.createIfNeeded(options.url); + this._resource.appendForwardSlash(); this._tileProtocol = options.tileProtocol; this._mapStyle = defaultValue(options.mapStyle, BingMapsStyle.AERIAL); this._culture = defaultValue(options.culture, ''); @@ -141,7 +142,7 @@ define([ this._readyPromise = when.defer(); var metadataResource = this._resource.getDerivedResource({ - url:'/REST/v1/Imagery/Metadata/' + this._mapStyle, + url:'REST/v1/Imagery/Metadata/' + this._mapStyle, queryParameters: { incl: 'ImageryProviders', key: this._key diff --git a/Specs/Scene/BingMapsImageryProviderSpec.js b/Specs/Scene/BingMapsImageryProviderSpec.js index 32c851c18b84..56482b8e9174 100644 --- a/Specs/Scene/BingMapsImageryProviderSpec.js +++ b/Specs/Scene/BingMapsImageryProviderSpec.js @@ -1,5 +1,6 @@ defineSuite([ 'Scene/BingMapsImageryProvider', + 'Core/appendForwardSlash', 'Core/DefaultProxy', 'Core/defined', 'Core/queryToObject', @@ -16,6 +17,7 @@ defineSuite([ 'ThirdParty/Uri' ], function( BingMapsImageryProvider, + appendForwardSlash, DefaultProxy, defined, queryToObject, @@ -147,7 +149,7 @@ defineSuite([ } function installFakeMetadataRequest(url, mapStyle, proxy) { - var expectedUrl = url + '/REST/v1/Imagery/Metadata/' + mapStyle; + var expectedUri = new Uri('REST/v1/Imagery/Metadata/' + mapStyle).resolve(new Uri(appendForwardSlash(url))); Resource._Implementations.loadAndExecuteScript = function(url, functionName) { var uri = new Uri(url); @@ -161,7 +163,7 @@ defineSuite([ expect(query.key).toBeDefined(); uri.query = undefined; - expect(uri.toString()).toStartWith(expectedUrl); + expect(uri.toString()).toStartWith(expectedUri.toString()); setTimeout(function() { window[functionName](createFakeMetadataResponse(mapStyle)); @@ -235,6 +237,42 @@ defineSuite([ }); }); + it('resolves readyPromise with a path', function() { + var url = 'http://fake.fake.invalid/some/subdirectory'; + var mapStyle = BingMapsStyle.ROAD; + + installFakeMetadataRequest(url, mapStyle); + installFakeImageRequest(); + + var provider = new BingMapsImageryProvider({ + url : url, + mapStyle : mapStyle + }); + + return provider.readyPromise.then(function(result) { + expect(result).toBe(true); + expect(provider.ready).toBe(true); + }); + }); + + it('resolves readyPromise with a path ending with a slash', function() { + var url = 'http://fake.fake.invalid/some/subdirectory/'; + var mapStyle = BingMapsStyle.ROAD; + + installFakeMetadataRequest(url, mapStyle); + installFakeImageRequest(); + + var provider = new BingMapsImageryProvider({ + url : url, + mapStyle : mapStyle + }); + + return provider.readyPromise.then(function(result) { + expect(result).toBe(true); + expect(provider.ready).toBe(true); + }); + }); + it('resolves readyPromise with Resource', function() { var url = 'http://fake.fake.invalid'; var mapStyle = BingMapsStyle.ROAD;