Skip to content

Commit f80dad6

Browse files
CopilotTingluoHuang
andcommitted
Add underscore to valid orchestration ID characters
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
1 parent baada7b commit f80dad6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

__test__/orchestration-id.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('getUserAgentWithOrchestrationId', () => {
2121
process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId
2222

2323
// Simulate the logic from getUserAgentWithOrchestrationId
24-
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
24+
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
2525
const result = `${baseUserAgent} orchestration-id/${sanitized}`
2626

2727
expect(result).toBe(
@@ -34,24 +34,24 @@ describe('getUserAgentWithOrchestrationId', () => {
3434
const orchestrationId = 'test@orchestration#123!abc$xyz'
3535

3636
// Simulate the logic from getUserAgentWithOrchestrationId
37-
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
37+
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
3838
const result = `${baseUserAgent} orchestration-id/${sanitized}`
3939

4040
expect(result).toBe(
4141
'actions/github-script orchestration-id/testorchestration123abcxyz'
4242
)
4343
})
4444

45-
test('preserves dots and hyphens in orchestration ID', () => {
45+
test('preserves dots, hyphens, and underscores in orchestration ID', () => {
4646
const baseUserAgent = 'actions/github-script'
47-
const orchestrationId = 'test.orchestration-123'
47+
const orchestrationId = 'test.orchestration-123_abc'
4848

4949
// Simulate the logic from getUserAgentWithOrchestrationId
50-
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
50+
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
5151
const result = `${baseUserAgent} orchestration-id/${sanitized}`
5252

5353
expect(result).toBe(
54-
'actions/github-script orchestration-id/test.orchestration-123'
54+
'actions/github-script orchestration-id/test.orchestration-123_abc'
5555
)
5656
})
5757

@@ -73,7 +73,7 @@ describe('getUserAgentWithOrchestrationId', () => {
7373
const orchestrationId = '@#$%^&*()'
7474

7575
// Simulate the logic from getUserAgentWithOrchestrationId
76-
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
76+
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
7777
const result = sanitized
7878
? `${baseUserAgent} orchestration-id/${sanitized}`
7979
: baseUserAgent

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36268,8 +36268,8 @@ function getUserAgentWithOrchestrationId(userAgent) {
3626836268
if (!orchestrationId) {
3626936269
return userAgent;
3627036270
}
36271-
// Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens
36272-
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '');
36271+
// Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
36272+
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '');
3627336273
if (!sanitized) {
3627436274
return userAgent;
3627536275
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function getUserAgentWithOrchestrationId(userAgent: string): string {
3434
return userAgent
3535
}
3636

37-
// Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens
38-
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '')
37+
// Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
38+
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
3939
if (!sanitized) {
4040
return userAgent
4141
}

0 commit comments

Comments
 (0)