File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,15 @@ function getQueryOrDefault(defaultVal) {
166166 if ( ! JQ_REPO_FIELD . val ( ) ) {
167167 JQ_REPO_FIELD . val ( defaultVal ) ;
168168 }
169- return JQ_REPO_FIELD . val ( ) ;
169+
170+ const val = JQ_REPO_FIELD . val ( ) ;
171+
172+ const isShorthand = / ^ [ \w \. - ] + \/ [ \w \. - ] + $ / ;
173+ if ( isShorthand . test ( val ) ) {
174+ return val ;
175+ } else {
176+ return new URL ( val ) . pathname ;
177+ }
170178}
171179
172180function hideFilterContainer ( ) {
Original file line number Diff line number Diff line change @@ -471,11 +471,11 @@ function initiate_search() {
471471 clear_old_data ( ) ;
472472
473473 let queryString = getQueryOrDefault ( "payne911/PieMenu" ) ;
474- let queryValues = queryString . split ( '/' ) . filter ( Boolean ) ;
474+ let queryValues = queryString . split ( '/' ) . filter ( s => s . length > 0 ) ;
475475
476476 let len = queryValues . length ;
477477 if ( len < 2 ) {
478- setMsg ( 'Please enter a valid query: it should contain two strings separated by a "/"' ) ;
478+ setMsg ( 'Please enter a valid query: it should contain two strings separated by a "/", or the full URL to a GitHub repo ' ) ;
479479 ga_faultyQuery ( queryString ) ;
480480 return ; // abort
481481 }
@@ -486,8 +486,8 @@ function initiate_search() {
486486 hideFilterContainer ( ) ;
487487 setMsg ( UF_MSG_SCANNING ) ;
488488
489- const user = queryValues [ len - 2 ] ;
490- const repo = queryValues [ len - 1 ] ;
489+ const user = queryValues [ 0 ] ;
490+ const repo = queryValues [ 1 ] ;
491491 if ( history . replaceState ) {
492492 history . replaceState ( { } , document . title , `?repo=${ user } /${ repo } ` ) ; // replace current URL param
493493 }
You can’t perform that action at this time.
0 commit comments