Skip to content

Commit 2b236f1

Browse files
authored
Add isNewDiscussion and add it to hasRichTextEditor (#177)
1 parent 9ef3a37 commit 2b236f1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ addTests('__urls_that_dont_match__', [
1010
'https://github.com/sindresorhus/refined-github/issues/new',
1111
'https://github.com/sindresorhus/refined-github/issues/new/choose',
1212
'https://github.com/sindresorhus/refined-github/issues/templates/edit',
13+
'https://github.com/orgs/community/discussions/new/choose',
1314
]);
1415

1516
export const is404 = (): boolean => /^(Page|File) not found · GitHub/.test(document.title); // #98; When logged out, it starts with "File"
@@ -213,6 +214,12 @@ addTests('isDiscussion', [
213214
'https://github.com/orgs/community/discussions/11202',
214215
]);
215216

217+
export const isNewDiscussion = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'discussions/new' || getOrg(url)?.path === 'discussions/new';
218+
addTests('isNewDiscussion', [
219+
'https://github.com/withastro/roadmap/discussions/new?category=proposal',
220+
'https://github.com/orgs/community/discussions/new?category=pull-requests',
221+
]);
222+
216223
export const isDiscussionList = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'discussions' || getOrg(url)?.path === 'discussions';
217224
addTests('isDiscussionList', [
218225
'https://github.com/tophf/mpiv/discussions',
@@ -654,7 +661,8 @@ export const hasRichTextEditor = (url: URL | HTMLAnchorElement | Location = loca
654661
|| isCompare(url)
655662
|| isRepliesSettings(url)
656663
|| hasReleaseEditor(url)
657-
|| isDiscussion(url);
664+
|| isDiscussion(url)
665+
|| isNewDiscussion(url);
658666

659667
addTests('hasCode', combinedTestOnly);
660668
/** Static code, not the code editor */

0 commit comments

Comments
 (0)