Skip to content

Commit 63005a4

Browse files
authored
Add isPRFile404 (#20)
1 parent 412259b commit 63005a4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ collect.set('isPRCommit', [
186186
]);
187187

188188
export const isPRCommit404 = (): boolean => isPRCommit() && document.title.startsWith('Commit range not found · Pull Request');
189+
export const isPRFile404 = (): boolean => isPRFiles() && document.title.startsWith('Commit range not found · Pull Request');
189190

190191
export const isPRConversation = (url: URL | Location = location): boolean => /^pull\/\d+$/.test(getRepoPath(url)!);
191192
collect.set('isPRConversation', [

test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ test('isPRCommit404', t => {
111111
t.false(pageDetect.isPRCommit404());
112112
});
113113

114+
test('isPRFile404', t => {
115+
document.title = 'Commit range not found · Pull Request #789 · sindresorhus/eslint-plugin-unicorn';
116+
location.href = 'https://github.com/sindresorhus/eslint-plugin-unicorn/pull/789/files/a58b37845f1b2660221de019e4ae6c736feedc26..eed168224d7994652b1d1ff69a5c8cebee223faf';
117+
t.true(pageDetect.isPRFile404());
118+
119+
document.title = 'Add `align-repository-header` feature by fregante · Pull Request #3313 · sindresorhus/refined-github';
120+
location.href = 'https://github.com/sindresorhus/refined-github/pull/3313/files/a14fb2c94eae3ca83a3a97688a171fcc3405524f..fbeeba9825f12b5ded9cd4bb04d5df4b0cf2f2a8';
121+
t.false(pageDetect.isPRFile404());
122+
});
123+
114124
test('getRepoPath', t => {
115125
const pairs = new Map<string, string | undefined>([
116126
[

0 commit comments

Comments
 (0)