Skip to content

Commit 4f25492

Browse files
authored
Add support for logged out 404 pages (#174)
1 parent b6f7b8d commit 4f25492

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ addTests('__urls_that_dont_match__', [
1212
'https://github.com/sindresorhus/refined-github/issues/templates/edit',
1313
]);
1414

15-
export const is404 = (): boolean => document.title.startsWith('Page not found · GitHub'); // #98
15+
export const is404 = (): boolean => /^(Page|File) not found · GitHub/.test(document.title); // #98; When logged out, it starts with "File"
1616

1717
export const is500 = (): boolean => document.title === 'Server Error · GitHub' || document.title === 'Unicorn! · GitHub' || document.title === '504 Gateway Time-out';
1818

test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ test('is404', t => {
7272
document.title = 'Page not found · GitHub';
7373
t.true(pageDetect.is404());
7474

75+
document.title = 'File not found · GitHub';
76+
t.true(pageDetect.is404());
77+
7578
document.title = 'examples/404: Page not found examples';
7679
t.false(pageDetect.is404());
7780

0 commit comments

Comments
 (0)