Skip to content

Commit 687b66e

Browse files
committed
fix: revert scope util to omit empty-string scope values
1 parent a2a54c4 commit 687b66e

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

lib/utils/scope-util.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
const isFormat = require('@node-oauth/formats');
22
const InvalidScopeError = require('../errors/invalid-scope-error');
3-
const toArray = s => Array.isArray(s) ? s : s.split(' ');
43

54
module.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
};

0 commit comments

Comments
 (0)