Skip to content

Commit 6d3ef45

Browse files
authored
Add hasFooEditor (#105)
1 parent 884d538 commit 6d3ef45

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,25 @@ collect.set('isEditingFile', [
298298
'https://github.com/sindresorhus/refined-github/edit/ghe-injection/source/background.ts',
299299
]);
300300

301+
export const hasFileEditor = (url: URL | HTMLAnchorElement | Location = location): boolean => isEditingFile(url) || isNewFile(url) || isDeletingFile(url);
302+
collect.set('hasFileEditor', combinedTestOnly);
303+
301304
export const isEditingRelease = (url: URL | HTMLAnchorElement | Location = location): boolean => Boolean(getRepo(url)?.path.startsWith('releases/edit'));
302305
collect.set('isEditingRelease', [
303306
'https://github.com/sindresorhus/refined-github/releases/edit/v1.2.3',
304307
]);
305308

309+
export const hasReleaseEditor = (url: URL | HTMLAnchorElement | Location = location): boolean => isEditingRelease(url) || isNewRelease(url);
310+
collect.set('hasReleaseEditor', combinedTestOnly);
311+
306312
export const isEditingWikiPage = (url: URL | HTMLAnchorElement | Location = location): boolean => isRepoWiki(url) && getCleanPathname(url).endsWith('/_edit');
307313
collect.set('isEditingWikiPage', [
308314
'https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit',
309315
]);
310316

317+
export const hasWikiPageEditor = (url: URL | HTMLAnchorElement | Location = location): boolean => isEditingWikiPage(url) || isNewWikiPage(url);
318+
collect.set('hasWikiPageEditor', combinedTestOnly);
319+
311320
export const isRepo = (url: URL | HTMLAnchorElement | Location = location): boolean => /^[^/]+\/[^/]+/.test(getCleanPathname(url))
312321
&& !reservedNames.includes(url.pathname.split('/', 2)[1]!)
313322
&& !isDashboard(url)
@@ -580,7 +589,7 @@ export const hasRichTextEditor = (url: URL | HTMLAnchorElement | Location = loca
580589
|| isNewIssue(url)
581590
|| isCompare(url)
582591
|| isRepliesSettings(url)
583-
|| isNewRelease(url)
592+
|| hasReleaseEditor(url)
584593
|| isDiscussion(url);
585594

586595
collect.set('hasCode', combinedTestOnly);

0 commit comments

Comments
 (0)