mirror of
https://github.com/actions/setup-node.git
synced 2025-12-17 10:51:38 +08:00
.
This commit is contained in:
18
node_modules/@octokit/rest/plugins/authentication/with-authorization-prefix.js
generated
vendored
18
node_modules/@octokit/rest/plugins/authentication/with-authorization-prefix.js
generated
vendored
@@ -1,23 +1,23 @@
|
||||
module.exports = withAuthorizationPrefix
|
||||
module.exports = withAuthorizationPrefix;
|
||||
|
||||
const atob = require('atob-lite')
|
||||
const atob = require("atob-lite");
|
||||
|
||||
const REGEX_IS_BASIC_AUTH = /^[\w-]+:/
|
||||
const REGEX_IS_BASIC_AUTH = /^[\w-]+:/;
|
||||
|
||||
function withAuthorizationPrefix (authorization) {
|
||||
function withAuthorizationPrefix(authorization) {
|
||||
if (/^(basic|bearer|token) /i.test(authorization)) {
|
||||
return authorization
|
||||
return authorization;
|
||||
}
|
||||
|
||||
try {
|
||||
if (REGEX_IS_BASIC_AUTH.test(atob(authorization))) {
|
||||
return `basic ${authorization}`
|
||||
return `basic ${authorization}`;
|
||||
}
|
||||
} catch (error) { }
|
||||
} catch (error) {}
|
||||
|
||||
if (authorization.split(/\./).length === 3) {
|
||||
return `bearer ${authorization}`
|
||||
return `bearer ${authorization}`;
|
||||
}
|
||||
|
||||
return `token ${authorization}`
|
||||
return `token ${authorization}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user