Skip to content

Commit

Permalink
Don't include the region param in authorizedRequest if it's already i…
Browse files Browse the repository at this point in the history
…n the URL
  • Loading branch information
DingoEatingFuzz committed Jan 28, 2021
1 parent f7f6828 commit b2faf8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui/app/services/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}
Expand Down
11 changes: 11 additions & 0 deletions ui/tests/unit/services/token-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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&region=already-here');
assert.equal(
this.server.handledRequests.pop().url,
'/path?query=param&region=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();

Expand Down

0 comments on commit b2faf8a

Please sign in to comment.