mirror of
https://github.com/actions/github-script.git
synced 2026-02-07 19:47:26 +00:00
Add underscore to valid orchestration ID characters
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
This commit is contained in:
parent
baada7bb39
commit
f80dad6b51
3 changed files with 11 additions and 11 deletions
|
|
@ -21,7 +21,7 @@ describe('getUserAgentWithOrchestrationId', () => {
|
||||||
process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId
|
process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
// Simulate the logic from getUserAgentWithOrchestrationId
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
|
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
||||||
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
||||||
|
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
|
|
@ -34,7 +34,7 @@ describe('getUserAgentWithOrchestrationId', () => {
|
||||||
const orchestrationId = 'test@orchestration#123!abc$xyz'
|
const orchestrationId = 'test@orchestration#123!abc$xyz'
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
// Simulate the logic from getUserAgentWithOrchestrationId
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
|
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
||||||
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
||||||
|
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
|
|
@ -42,16 +42,16 @@ describe('getUserAgentWithOrchestrationId', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('preserves dots and hyphens in orchestration ID', () => {
|
test('preserves dots, hyphens, and underscores in orchestration ID', () => {
|
||||||
const baseUserAgent = 'actions/github-script'
|
const baseUserAgent = 'actions/github-script'
|
||||||
const orchestrationId = 'test.orchestration-123'
|
const orchestrationId = 'test.orchestration-123_abc'
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
// Simulate the logic from getUserAgentWithOrchestrationId
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
|
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
||||||
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
||||||
|
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
'actions/github-script orchestration-id/test.orchestration-123'
|
'actions/github-script orchestration-id/test.orchestration-123_abc'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ describe('getUserAgentWithOrchestrationId', () => {
|
||||||
const orchestrationId = '@#$%^&*()'
|
const orchestrationId = '@#$%^&*()'
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
// Simulate the logic from getUserAgentWithOrchestrationId
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
|
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
||||||
const result = sanitized
|
const result = sanitized
|
||||||
? `${baseUserAgent} orchestration-id/${sanitized}`
|
? `${baseUserAgent} orchestration-id/${sanitized}`
|
||||||
: baseUserAgent
|
: baseUserAgent
|
||||||
|
|
|
||||||
4
dist/index.js
vendored
4
dist/index.js
vendored
|
|
@ -36268,8 +36268,8 @@ function getUserAgentWithOrchestrationId(userAgent) {
|
||||||
if (!orchestrationId) {
|
if (!orchestrationId) {
|
||||||
return userAgent;
|
return userAgent;
|
||||||
}
|
}
|
||||||
// Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens
|
// Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '');
|
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '');
|
||||||
if (!sanitized) {
|
if (!sanitized) {
|
||||||
return userAgent;
|
return userAgent;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ function getUserAgentWithOrchestrationId(userAgent: string): string {
|
||||||
return userAgent
|
return userAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens
|
// Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
|
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
||||||
if (!sanitized) {
|
if (!sanitized) {
|
||||||
return userAgent
|
return userAgent
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue