@@ -682,7 +682,7 @@ export class LaunchpadCommand extends QuickCommand<State> {
682
682
quickpick . items = getLaunchpadQuickPickItems ( context . result . items , true ) ;
683
683
684
684
// Show just the option to toggle search on if nothing found
685
- if ( quickpick . activeItems . length === 0 && ! isSupportedLaunchpadPullRequestUrl ( value ) ) {
685
+ if ( quickpick . activeItems . length === 0 && ! isSupportedLaunchpadPullRequestSearchUrl ( value ) ) {
686
686
quickpick . items = [ toggleSearchOnItem ] ;
687
687
return true ;
688
688
}
@@ -721,7 +721,7 @@ export class LaunchpadCommand extends QuickCommand<State> {
721
721
}
722
722
723
723
// If a supported PR URL was entered but no existing items match outside of search mode, turn on search mode and search the API.
724
- if ( isSupportedLaunchpadPullRequestUrl ( value ) ) {
724
+ if ( isSupportedLaunchpadPullRequestSearchUrl ( value ) ) {
725
725
context . isSearching = true ;
726
726
await updateItems ( quickpick , true ) ;
727
727
} else if ( quickpick . activeItems . length === 0 || quickpick . activeItems [ 0 ] === toggleSearchOnItem ) {
@@ -1593,13 +1593,23 @@ function isLaunchpadTargetActionQuickPickItem(item: any): item is QuickPickItemO
1593
1593
}
1594
1594
1595
1595
function isGitHubPullRequestUrl ( search : string ) {
1596
- return search . includes ( 'github.com' ) && search . includes ( '/pull/' ) ;
1596
+ try {
1597
+ const url = new URL ( search ) ;
1598
+ return url . host === 'github.com' && url . pathname . includes ( '/pull/' ) ;
1599
+ } catch {
1600
+ return false ;
1601
+ }
1597
1602
}
1598
1603
1599
1604
function isGitLabPullRequestUrl ( search : string ) {
1600
- return search . includes ( 'gitlab.com' ) && search . includes ( '/merge_requests/' ) ;
1605
+ try {
1606
+ const url = new URL ( search ) ;
1607
+ return url . host === 'gitlab.com' && url . pathname . includes ( '/merge_requests/' ) ;
1608
+ } catch {
1609
+ return false ;
1610
+ }
1601
1611
}
1602
1612
1603
- function isSupportedLaunchpadPullRequestUrl ( search : string ) {
1613
+ function isSupportedLaunchpadPullRequestSearchUrl ( search : string ) {
1604
1614
return isGitHubPullRequestUrl ( search ) || isGitLabPullRequestUrl ( search ) ;
1605
1615
}
0 commit comments