Skip to content

Add support for logged out 404 pages #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ addTests('__urls_that_dont_match__', [
'https://github.com/sindresorhus/refined-github/issues/templates/edit',
]);

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

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

Expand Down
3 changes: 3 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ test('is404', t => {
document.title = 'Page not found · GitHub';
t.true(pageDetect.is404());

document.title = 'File not found · GitHub';
t.true(pageDetect.is404());

document.title = 'examples/404: Page not found examples';
t.false(pageDetect.is404());

Expand Down