diff --git a/lib/client.js b/lib/client.js index 25431579..dc8f927c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -272,7 +272,7 @@ class BaseClient { } // TODO: is the replace needed? - return target.href.replace('+', '%20'); + return target.href.replace(/\+/g, '%20'); } authorizationPost(params = {}) { diff --git a/test/client/client_instance.test.js b/test/client/client_instance.test.js index 100ec71b..8466721e 100644 --- a/test/client/client_instance.test.js +++ b/test/client/client_instance.test.js @@ -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 () {