Simplify constructor by handling undefined in helper method
Co-authored-by: TingluoHuang <[email protected]>
This commit is contained in:
co-authored by
TingluoHuang
parent
48a7cdbf9c
commit
97f5a6f0dc
@@ -147,9 +147,7 @@ export class HttpClient {
|
|||||||
handlers?: ifm.RequestHandler[],
|
handlers?: ifm.RequestHandler[],
|
||||||
requestOptions?: ifm.RequestOptions
|
requestOptions?: ifm.RequestOptions
|
||||||
) {
|
) {
|
||||||
this.userAgent = userAgent
|
this.userAgent = this._getUserAgentWithOrchestrationId(userAgent)
|
||||||
? this._getUserAgentWithOrchestrationId(userAgent)
|
|
||||||
: undefined
|
|
||||||
this.handlers = handlers || []
|
this.handlers = handlers || []
|
||||||
this.requestOptions = requestOptions
|
this.requestOptions = requestOptions
|
||||||
if (requestOptions) {
|
if (requestOptions) {
|
||||||
@@ -818,7 +816,12 @@ export class HttpClient {
|
|||||||
return proxyAgent
|
return proxyAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getUserAgentWithOrchestrationId(userAgent: string): string {
|
private _getUserAgentWithOrchestrationId(
|
||||||
|
userAgent?: string
|
||||||
|
): string | undefined {
|
||||||
|
if (!userAgent) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
const orchId = process.env['ACTIONS_ORCHESTRATION_ID']
|
const orchId = process.env['ACTIONS_ORCHESTRATION_ID']
|
||||||
if (orchId) {
|
if (orchId) {
|
||||||
// Sanitize the orchestration ID to ensure it contains only valid characters
|
// Sanitize the orchestration ID to ensure it contains only valid characters
|
||||||
|
|||||||
Reference in New Issue
Block a user