Skip to content
This repository was archived by the owner on Feb 25, 2019. It is now read-only.

Trim whitespace around redirect URIs #221

Merged
merged 1 commit into from
Sep 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions models/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ var Client = Modinha.define('clients', {
conform: 'Must follow guidelines in OpenID Connect Registration 1.0 ' +
'specification for client metadata'
},
set: function (source) {
// If redirect URIs were given
if (Array.isArray(source.redirect_uris)) {
// Iterate through each one
for (var i = 0; i < source.redirect_uris.length; i++) {
if (typeof source.redirect_uris[i] === 'string') {
// And remove any leading or trailing whitespace
source.redirect_uris[i] = source.redirect_uris[i].trim()
}
}
}
// Lastly, set the new URIs
this.redirect_uris = source.redirect_uris
},
conform: function (value, instance) {
var valid = true
var inDevelopment = process.env.NODE_ENV === 'development' ||
Expand Down
26 changes: 26 additions & 0 deletions test/unit/models/clientSpec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,32 @@ describe 'Client', ->



describe 'initialization', ->

describe 'redirect_uris', ->

before ->
client = new Client
redirect_uris: [
" https://example.org",
"https://example.net ",
" https://example.com "
]

it 'should trim leading whitespace', ->
client.redirect_uris[0].should.equal 'https://example.org'

it 'should trim trailing whitespace', ->
client.redirect_uris[1].should.equal 'https://example.net'

it 'should trim both leading and trailing whitespace', ->
client.redirect_uris[2].should.equal 'https://example.com'






describe 'configuration', ->

{client,configuration,token} = {}
Expand Down