File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed
Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change 11const isFormat = require ( '@node-oauth/formats' ) ;
22const InvalidScopeError = require ( '../errors/invalid-scope-error' ) ;
3- const toArray = s => Array . isArray ( s ) ? s : s . split ( ' ' ) ;
43
54module . exports = {
65 parseScope : function ( requestedScope ) {
7- if ( typeof requestedScope === 'undefined' || requestedScope === null ) {
8- return undefined ;
9- }
10-
11- const internalScope = toArray ( requestedScope ) ;
12-
13- if ( internalScope . length === 0 ) {
6+ if ( ! isFormat . nqschar ( requestedScope ) ) {
147 throw new InvalidScopeError ( 'Invalid parameter: `scope`' ) ;
158 }
169
17- internalScope . forEach ( value => {
18- if ( ! isFormat . nqschar ( value ) ) {
19- throw new InvalidScopeError ( 'Invalid parameter: `scope`' ) ;
20- }
21- } ) ;
10+ if ( requestedScope == null ) {
11+ return undefined ;
12+ }
2213
23- return internalScope ;
14+ return Array . isArray ( requestedScope ) ? requestedScope : requestedScope . split ( ' ' ) ;
2415 }
2516} ;
You can’t perform that action at this time.
0 commit comments