mirror of https://github.com/actions/toolkit
`command.ts` generalize substitutions
Looks better than repeating the same thing over and over...pull/1472/head
parent
91d3933eb5
commit
bfd23b02d9
|
@ -77,18 +77,15 @@ class Command {
|
|||
}
|
||||
}
|
||||
|
||||
function escapeChar(ch: string): string {
|
||||
return ch.replace(/[%\r\n:,]/g, c =>
|
||||
'%' + c.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0'))
|
||||
}
|
||||
|
||||
function escapeData(s: any): string {
|
||||
return toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
return toCommandValue(s).replace(/%\r\n/g, escapeChar)
|
||||
}
|
||||
|
||||
function escapeProperty(s: any): string {
|
||||
return toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
.replace(/:/g, '%3A')
|
||||
.replace(/,/g, '%2C')
|
||||
return toCommandValue(s).replace(/[%\r\n:,]/g, escapeChar)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue