Skip to content

Commit 2165fa7

Browse files
committed
Bug-fix: proper parsing of HTML-encoded repo input
1 parent 7ef18e6 commit 2165fa7

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

docs/src/index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,21 @@ function drawAddTokenBtn(accessToken) {
102102
JQ_POPUP_TITLE.html(verb + ' GitHub Access Token');
103103
}
104104

105-
function automaticSearch(split_url) {
106-
JQ_REPO_FIELD.val(split_url[1]);
105+
function automaticSearch(searchValue) {
106+
JQ_REPO_FIELD.val(searchValue);
107107
JQ_SEARCH_BTN.click();
108108
}
109109

110-
/* Automatically queries when an URL parameter is present. */
111-
let url = window.location.href.split('?repository=');
112-
if (url.length === 2) {
113-
automaticSearch(url);
114-
} else {
115-
url = window.location.href.split('?repo=');
116-
if (url.length === 2) {
117-
automaticSearch(url);
110+
function getRepoNameFromUrl() {
111+
let repo = new URLSearchParams(location.search).get('repo');
112+
if (!repo) {
113+
repo = new URLSearchParams(location.search).get('repository');
118114
}
115+
return repo;
116+
}
117+
118+
/* Automatically queries when an URL parameter is present. */
119+
const query = getRepoNameFromUrl();
120+
if (query) {
121+
automaticSearch(query);
119122
}

0 commit comments

Comments
 (0)