mirror of
https://github.com/github/codeql-action.git
synced 2026-04-02 17:52:19 +00:00
Use .match in isAuthToken and add repeated call to test
This commit is contained in:
2
lib/start-proxy-action.js
generated
2
lib/start-proxy-action.js
generated
@@ -103998,7 +103998,7 @@ var GITHUB_TOKEN_PATTERNS = [
|
||||
];
|
||||
function isAuthToken(value, patterns = GITHUB_TOKEN_PATTERNS) {
|
||||
for (const { type: type2, pattern } of patterns) {
|
||||
if (pattern.test(value)) {
|
||||
if (value.match(pattern)) {
|
||||
return type2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ test("isAuthToken", (t) => {
|
||||
|
||||
// Token types for strings that are tokens.
|
||||
t.is(isAuthToken(`ghp_${makeTestToken()}`), TokenType.PersonalAccessClassic);
|
||||
t.is(isAuthToken(`ghp_${makeTestToken()}`), TokenType.PersonalAccessClassic);
|
||||
t.is(
|
||||
isAuthToken(`ghs_${makeTestToken(255)}`),
|
||||
TokenType.AppInstallationAccess,
|
||||
|
||||
@@ -88,7 +88,7 @@ export function isAuthToken(
|
||||
patterns: TokenPattern[] = GITHUB_TOKEN_PATTERNS,
|
||||
) {
|
||||
for (const { type, pattern } of patterns) {
|
||||
if (pattern.test(value)) {
|
||||
if (value.match(pattern)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user