Skip to content

Commit 0135467

Browse files
committed
allow for use in projects
1 parent 85ad832 commit 0135467

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

src/ChromeExtension/js/urls.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ const getCurrentActiveURL = async () =>{
2222
const isGitHubIssueUrl = (url) => {
2323

2424
if(url === null){
25-
url = window.location.href;
26-
}
27-
28-
let pattern = /^(https?:\/\/)github\.com\/.+\/.+\/issues\/\d+/i;
29-
30-
return pattern.test(url);
25+
url = window.location.href;
26+
}
27+
28+
const issueUrlPattern = /^(https?:\/\/)github\.com\/.+\/.+\/issues\/\d+/i;
29+
30+
const projectIssueUrlPattern = /^https:\/\/github.com\/(orgs|users)\/(?<owner>\w+)\/projects\/\d+(?:.*)(?:[?|&]pane=\S+&*)(?:issue=\S+)/i;
31+
32+
return issueUrlPattern.test(url) || projectIssueUrlPattern.test(url);
3133
}
3234

3335
const isGitHubPullRequestUrl = (url) => {
@@ -58,13 +60,23 @@ const getGitHubOwner = (url) => {
5860
url = window.location.href;
5961
}
6062

61-
const expression = /https:\/\/github.com\/(?<owner>[^\/]+)?(.*)/i
63+
const issueOrPrOwnerPattern = /https:\/\/github.com\/(?<owner>[\w]+)\/\w+\/(pull|issues)\/.+/i
6264

63-
const matches = url.match(expression);
65+
if(issueOrPrOwnerPattern.test(url)){
66+
67+
const matches = url.match(issueOrPrOwnerPattern);
6468

65-
const owner = matches?.groups['owner'];
69+
return matches?.groups['owner'];
70+
}
6671

67-
return owner;
72+
const projectIssuetOwnerPattern = /https:\/\/github.com\/(orgs|users)\/(?<owner>\w+)\/projects\/\d+(?:.*)(?:[?|&]pane=\S+&*)(?:issue=\S+)/i
73+
74+
if(projectIssuetOwnerPattern.test(url)){
75+
76+
const matches = url.match(projectIssuetOwnerPattern);
77+
78+
return matches?.groups['owner'];
79+
}
6880
}
6981

7082
const canLoadRepliesForUrl = (config,url) => {

src/ChromeExtension/pages/content-script/content-script.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11

22
const showHideSavedRepliesButton = async (showButton) => {
33

4-
const showSavedRepliesButton =
4+
var showSavedRepliesButton =
55
document.querySelector(".show-saved-replies-button-container");
66

7+
if (showSavedRepliesButton === undefined || showSavedRepliesButton == null) {
8+
9+
showSavedRepliesButton = createShowSavedRepliesButton();
10+
11+
await addShowSavedRepliesClickHandler(showSavedRepliesButton);
12+
13+
document.body.appendChild(showSavedRepliesButton);
14+
}
15+
716
if (showSavedRepliesButton !== undefined) {
17+
818
if (showButton !== undefined && showButton) {
919
showSavedRepliesButton?.classList?.remove("hide");
1020
} else {
@@ -31,7 +41,7 @@ const main = async () => {
3141
const showSavedRepliesButton = createShowSavedRepliesButton();
3242

3343
await addShowSavedRepliesClickHandler(showSavedRepliesButton);
34-
44+
3545
document.body.appendChild(showSavedRepliesButton);
3646
}
3747
}

0 commit comments

Comments
 (0)