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 {
|
function escapeData(s: any): string {
|
||||||
return toCommandValue(s)
|
return toCommandValue(s).replace(/%\r\n/g, escapeChar)
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeProperty(s: any): string {
|
function escapeProperty(s: any): string {
|
||||||
return toCommandValue(s)
|
return toCommandValue(s).replace(/[%\r\n:,]/g, escapeChar)
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A')
|
|
||||||
.replace(/:/g, '%3A')
|
|
||||||
.replace(/,/g, '%2C')
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue