3 var escapeStringRegexp
= require('escape-string-regexp');
4 var unauthorizedRedirectMap
= require('./unauthorized-redirect-map');
6 var unauthorizedUrlRedirectRegexList
= Object
.keys(unauthorizedRedirectMap
).map(redirectKey
=> {
7 const redirectUrl
= unauthorizedRedirectMap
[redirectKey
];
8 return new RegExp(`${escapeStringRegexp(redirectUrl)}(\\/(\\?.*)?)?$`);
11 function checkAlreadyOnUnauthorizedUrl(url
) {
12 // Avoid a redirect loop even when someone is forcing a token via
13 // `?access_token=xxxtoken` query parameter or `Authorization: bearer xxxtoken` header
14 return unauthorizedUrlRedirectRegexList
.some(unauthorizedRe
=> {
15 return url
.match(unauthorizedRe
);
19 module
.exports
= checkAlreadyOnUnauthorizedUrl
;