@@ -215,32 +215,21 @@ export const make = Effect.gen(function* () {
215215 ) ;
216216 } ;
217217
218- return SourceControlProvider . SourceControlProvider . of ( {
219- kind : "github" ,
220- resolveLink : ( input ) => {
221- const match = / ^ \/ ( [ \w . - ] + ) \/ ( [ \w . - ] + ) \/ (?: p u l l | i s s u e s ) \/ ( [ 1 - 9 ] \d * ) (?: \/ .* ) ? $ / . exec (
222- input . url . pathname ,
223- ) ;
224- if ( ! match ) return undefined ;
225- return Effect . fn ( "GitHubSourceControlProvider.resolveLink" ) (
226- function * ( ) {
227- const result = yield * github . execute ( {
228- cwd : input . cwd ,
229- args : [
230- "api" ,
231- "--hostname" ,
232- input . url . host ,
233- `repos/${ match [ 1 ] } /${ match [ 2 ] } /issues/${ match [ 3 ] } ` ,
234- "--jq" ,
235- "{title, body}" ,
236- ] ,
237- env : { GH_PROMPT_DISABLED : "1" } ,
238- timeoutMs : 3_000 ,
239- maxOutputBytes : 32_000 ,
240- } ) ;
241- const subject = yield * decodeLinkSubject ( result . stdout ) ;
242- return { title : subject . title , body : subject . body } ;
243- } ,
218+ const readLinkSubject = Effect . fn ( "GitHubSourceControlProvider.readLinkSubject" ) ( function * (
219+ input : { readonly cwd : string ; readonly url : URL } ,
220+ endpoint : string ,
221+ ) {
222+ return yield * github
223+ . execute ( {
224+ cwd : input . cwd ,
225+ args : [ "api" , "--hostname" , input . url . host , endpoint , "--jq" , "{title, body}" ] ,
226+ env : { GH_PROMPT_DISABLED : "1" } ,
227+ timeoutMs : 3_000 ,
228+ maxOutputBytes : 32_000 ,
229+ } )
230+ . pipe (
231+ Effect . flatMap ( ( result ) => decodeLinkSubject ( result . stdout ) ) ,
232+ Effect . map ( ( subject ) => ( { title : subject . title , body : subject . body } ) ) ,
244233 Effect . mapError (
245234 ( cause ) =>
246235 new SourceControlProviderError ( {
@@ -251,7 +240,19 @@ export const make = Effect.gen(function* () {
251240 cause,
252241 } ) ,
253242 ) ,
254- ) ( ) ;
243+ ) ;
244+ } ) ;
245+
246+ return SourceControlProvider . SourceControlProvider . of ( {
247+ kind : "github" ,
248+ resolveLink : ( input ) => {
249+ // Automatic enrichment must not send ambient CLI credentials to a host from message text.
250+ if ( input . url . host !== "github.com" ) return undefined ;
251+ const match = / ^ \/ ( [ \w . - ] + ) \/ ( [ \w . - ] + ) \/ (?: p u l l | i s s u e s ) \/ ( [ 1 - 9 ] \d * ) (?: \/ .* ) ? $ / . exec (
252+ input . url . pathname ,
253+ ) ;
254+ if ( ! match ) return undefined ;
255+ return readLinkSubject ( input , `repos/${ match [ 1 ] } /${ match [ 2 ] } /issues/${ match [ 3 ] } ` ) ;
255256 } ,
256257 listChangeRequests,
257258 getChangeRequest : ( input ) =>
0 commit comments