@@ -624,16 +624,28 @@ export function registerCommands(
624624 return ! ! contextAsPath . path ;
625625 }
626626
627+ function prNumberFromUriPath ( path : string ) : number | undefined {
628+ const trimPath = path . startsWith ( '/' ) ? path . substring ( 1 ) : path ;
629+ if ( ! Number . isNaN ( Number ( trimPath ) ) ) {
630+ return Number ( trimPath ) ;
631+ }
632+ // This is a base64 encoded PR number like: /MTIz
633+ const decoded = Number ( Buffer . from ( trimPath , 'base64' ) . toString ( 'utf8' ) ) ;
634+ if ( ! Number . isNaN ( decoded ) ) {
635+ return decoded ;
636+ }
637+ }
638+
627639 context . subscriptions . push ( vscode . commands . registerCommand ( 'pr.checkoutFromDescription' , async ( ctx : OverviewContext | { path : string } | undefined ) => {
628640 if ( ! ctx ) {
629641 return vscode . window . showErrorMessage ( vscode . l10n . t ( 'No pull request context provided for checkout.' ) ) ;
630642 }
631643
632644 if ( contextHasPath ( ctx ) ) {
633645 const { path } = ctx ;
634- const prNumber = Number ( Buffer . from ( path . substring ( 1 ) , 'base64' ) . toString ( 'utf8' ) ) ;
635- if ( Number . isNaN ( prNumber ) ) {
636- return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to parse pull request number.' ) ) ;
646+ const prNumber = prNumberFromUriPath ( path ) ;
647+ if ( ! prNumber ) {
648+ return vscode . window . showErrorMessage ( vscode . l10n . t ( 'No pull request number found in context path .' ) ) ;
637649 }
638650 const folderManager = reposManager . folderManagers [ 0 ] ;
639651 const pullRequest = await folderManager . fetchById ( folderManager . gitHubRepositories [ 0 ] , Number ( prNumber ) ) ;
@@ -659,8 +671,8 @@ export function registerCommands(
659671
660672 if ( contextHasPath ( ctx ) ) {
661673 const { path } = ctx ;
662- const prNumber = Number ( Buffer . from ( path . substring ( 1 ) , 'base64' ) . toString ( 'utf8' ) ) ;
663- if ( Number . isNaN ( prNumber ) ) {
674+ const prNumber = prNumberFromUriPath ( path ) ;
675+ if ( ! prNumber ) {
664676 return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to parse pull request number.' ) ) ;
665677 }
666678
0 commit comments