File tree 1 file changed +5
-14
lines changed 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change 1
1
const isFormat = require ( '@node-oauth/formats' ) ;
2
2
const InvalidScopeError = require ( '../errors/invalid-scope-error' ) ;
3
- const toArray = s => Array . isArray ( s ) ? s : s . split ( ' ' ) ;
4
3
5
4
module . exports = {
6
5
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 ) ) {
14
7
throw new InvalidScopeError ( 'Invalid parameter: `scope`' ) ;
15
8
}
16
9
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
+ }
22
13
23
- return internalScope ;
14
+ return Array . isArray ( requestedScope ) ? requestedScope : requestedScope . split ( ' ' ) ;
24
15
}
25
16
} ;
You can’t perform that action at this time.
0 commit comments