Skip to content

Commit dc3d3ef

Browse files
committed
fix: update permitted GitHub token characters
Our commit linter is flagging the GitHub blog URL for being longer than 100 characters so here it is as a tinyurl. Refs: https://tinyurl.com/2p9cz8m3 Fixes: #617
1 parent 64a977c commit dc3d3ef

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

lib/auth.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function check(username, token) {
2828
if (typeof token !== 'string') {
2929
errorExit(`token must be a string, received ${typeof token}`);
3030
}
31-
if (!/^[0-9a-f]+$/.test(token)) {
32-
errorExit(`token must be lowercase hexadecimal, received ${token}`);
31+
if (!/^[A-Za-z0-9_]+$/.test(token)) {
32+
errorExit(`token is misformatted: ${token}`);
3333
}
3434
}
3535

test/unit/auth.test.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,25 @@ describe('auth', async function() {
102102
it('does not accept an invalid token format', async function() {
103103
this.timeout(2000);
104104
await runAuthScript(
105-
{ HOME: { username: 'nyancat', token: '0123456789ABCDEF' } },
105+
{ HOME: { username: 'nyancat', token: '@fhqwhgads' } },
106106
[],
107-
'token must be lowercase hexadecimal, received 0123456789ABCDEF\n'
107+
'token is misformatted: @fhqwhgads\n'
108+
);
109+
});
110+
111+
it('permits capital letters in token format', async function() {
112+
this.timeout(2000);
113+
await runAuthScript(
114+
{ HOME: { username: 'nyancat', token: '0123456789ABCDEF' } },
115+
['{"github":"bnlhbmNhdDowMTIzNDU2Nzg5QUJDREVG"}']
116+
);
117+
});
118+
119+
it('permits underscores in token format', async function() {
120+
this.timeout(2000);
121+
await runAuthScript(
122+
{ HOME: { username: 'nyancat', token: 'ghp_0123456789ABCDEF' } },
123+
['{"github":"bnlhbmNhdDpnaHBfMDEyMzQ1Njc4OUFCQ0RFRg=="}']
108124
);
109125
});
110126
});

0 commit comments

Comments
 (0)