Skip to content

Commit

Permalink
fix: consistent space encoding in authorizationUrl (#627)
Browse files Browse the repository at this point in the history
Fixes #626
  • Loading branch information
kg0r0 committed Oct 11, 2023
1 parent 53458e0 commit ad68223
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class BaseClient {
}

// TODO: is the replace needed?
return target.href.replace('+', '%20');
return target.href.replace(/\+/g, '%20');
}

authorizationPost(params = {}) {
Expand Down
10 changes: 10 additions & 0 deletions test/client/client_instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ describe('Client', () => {
this.client.authorizationUrl(true);
}).to.throw(TypeError, 'params must be a plain object');
});

it('returns a space-delimited scope parameter', function () {
expect(
this.client.authorizationUrl({
state: 'state',
scope: 'openid profile email',
}),
).to.eql('https://op.example.com/auth?client_id=identifier&scope=openid%20profile%20email&response_type=code&state=state');
});

});

describe('#endSessionUrl', function () {
Expand Down

0 comments on commit ad68223

Please sign in to comment.