@@ -358,8 +358,8 @@ export class GitHubClient {
358358 case ProxyType . Common :
359359 case ProxyType . Reverse : {
360360 const proxyType = proxy . type
361- this . base_url = get_base_url ( type , { proxyUrl : proxy . address , proxyType } )
362361 this . api_url = get_api_base_url ( type , { proxyUrl : proxy . address , proxyType } )
362+ this . currentRequestConfig . url = this . api_url
363363 break
364364 }
365365 case ProxyProtocol . HTTP :
@@ -416,9 +416,20 @@ export class GitHubClient {
416416 return jwt . sign ( payload , this . Private_Key ! , { algorithm : 'RS256' } )
417417 }
418418
419+ /**
420+ * 获取当前请求的配置
421+ * @returns 当前请求的配置对象
422+ */
423+ private getCurrentRequestConfig ( ) : RequestConfigType {
424+ return {
425+ ...this . currentRequestConfig ,
426+ url : this . api_url
427+ }
428+ }
429+
419430 /**
420431 * 设置当前请求的配置
421- * @protected - 仅在类内部访问
432+ * @protected - 仅在父类与子类中方法中可访问
422433 * @param config - 配置对象,包含以下属性:
423434 * - url: 请求的URL
424435 * - token: 认证令牌
@@ -435,13 +446,13 @@ export class GitHubClient {
435446 * @returns 返回一个新的 Request 实例
436447 */
437448 private createRequest ( ) : Request {
438- const { url, token, tokenType } = this . currentRequestConfig
449+ const { url, token, tokenType } = this . getCurrentRequestConfig ( )
439450 const proxyConfig = this . proxy ?. type !== 'common' ? this . proxy : null
440451 const customHeaders = {
441452 'X-GitHub-Api-Version' : '2022-11-28' ,
442453 Accept : 'application/vnd.github+json'
443454 }
444- return new Request ( url ?? this . api_url , tokenType , token , proxyConfig , customHeaders )
455+ return new Request ( url ! , tokenType , token , proxyConfig , customHeaders )
445456 }
446457
447458 /**
@@ -458,6 +469,9 @@ export class GitHubClient {
458469 ) : Promise < ApiResponseType > {
459470 try {
460471 if ( ! path ) throw new Error ( MissingRequestPathMsg )
472+ this . setRequestConfig ( {
473+ token : this . userToken
474+ } )
461475 const request = this . createRequest ( )
462476 const req = await request . get ( path , parms , customHeaders )
463477 if ( ( req . statusCode === 403 || req . statusCode === 429 ) && req . headers [ 'x-ratelimit-remaining' ] === '0' ) {
@@ -489,6 +503,9 @@ export class GitHubClient {
489503 ) : Promise < ApiResponseType > {
490504 try {
491505 if ( ! path ) throw new Error ( MissingRequestPathMsg )
506+ this . setRequestConfig ( {
507+ token : this . userToken
508+ } )
492509 const request = this . createRequest ( )
493510 const req = await request . post ( path , data , customHeaders )
494511 if ( ( req . statusCode === 403 || req . statusCode === 429 ) && req . headers [ 'x-ratelimit-remaining' ] === '0' ) {
@@ -522,6 +539,9 @@ export class GitHubClient {
522539 ) : Promise < ApiResponseType > {
523540 try {
524541 if ( ! path ) throw new Error ( MissingRequestPathMsg )
542+ this . setRequestConfig ( {
543+ token : this . userToken
544+ } )
525545 const request = this . createRequest ( )
526546 const req = await request . patch ( path , params , data , customHeaders )
527547 if ( ( req . statusCode === 403 || req . statusCode === 429 ) && req . headers [ 'x-ratelimit-remaining' ] === '0' ) {
@@ -553,6 +573,9 @@ export class GitHubClient {
553573 ) : Promise < ApiResponseType > {
554574 try {
555575 if ( ! path ) throw new Error ( MissingRequestPathMsg )
576+ this . setRequestConfig ( {
577+ token : this . userToken
578+ } )
556579 const request = this . createRequest ( )
557580 const req = await request . put ( path , data , customHeaders )
558581 if ( ( req . statusCode === 403 || req . statusCode === 429 ) && req . headers [ 'x-ratelimit-remaining' ] === '0' ) {
@@ -586,6 +609,9 @@ export class GitHubClient {
586609 ) : Promise < ApiResponseType > {
587610 try {
588611 if ( ! path ) throw new Error ( MissingRequestPathMsg )
612+ this . setRequestConfig ( {
613+ token : this . userToken
614+ } )
589615 const request = this . createRequest ( )
590616 const req = await request . delete ( path , params , data , customHeaders )
591617 if ( ( req . statusCode === 403 || req . statusCode === 429 ) && req . headers [ 'x-ratelimit-remaining' ] === '0' ) {
0 commit comments