Don't include the region param in authorizedRequest if it's already in the URL
This commit is contained in:
parent
d44e0772f7
commit
f487562955
|
@ -94,7 +94,7 @@ export default class TokenService extends Service {
|
|||
authorizedRequest(url, options) {
|
||||
if (this.get('system.shouldIncludeRegion')) {
|
||||
const region = this.get('system.activeRegion');
|
||||
if (region) {
|
||||
if (region && url.indexOf('region=') === -1) {
|
||||
url = addParams(url, { region });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,17 @@ module('Unit | Service | Token', function(hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test('authorizedRequest does not include the region param when the region param is already in the URL', function(assert) {
|
||||
const token = this.subject();
|
||||
|
||||
token.authorizedRequest('/path?query=param®ion=already-here');
|
||||
assert.equal(
|
||||
this.server.handledRequests.pop().url,
|
||||
'/path?query=param®ion=already-here',
|
||||
'The region param that is already in the URL takes precedence over the region in the service'
|
||||
);
|
||||
});
|
||||
|
||||
test('authorizedRawRequest bypasses adding the region param', function(assert) {
|
||||
const token = this.subject();
|
||||
|
||||
|
|
Loading…
Reference in New Issue