mirror of
https://github.com/actions/cache.git
synced 2025-04-21 22:08:41 +00:00
Encode cache keys
* remove restriction on commas in keys * avoid 404 during save when characters like slashes are used in keys fixes #53
This commit is contained in:
parent
f66a56e59e
commit
cda609ee82
1 changed files with 8 additions and 11 deletions
|
@ -17,12 +17,16 @@ async function run() {
|
|||
);
|
||||
core.debug(`Cache Path: ${cachePath}`);
|
||||
|
||||
const primaryKey = core.getInput(Inputs.Key, { required: true });
|
||||
const keys = [
|
||||
core.getInput(Inputs.Key, { required: true }),
|
||||
...core
|
||||
.getInput(Inputs.RestoreKeys)
|
||||
.split(/\s*\n\s*/)
|
||||
.filter(x => x)
|
||||
].map(key => encodeURIComponent(key).replace(/%/g, " "));
|
||||
const primaryKey = keys[0];
|
||||
core.saveState(State.CacheKey, primaryKey);
|
||||
|
||||
const restoreKeys = core.getInput(Inputs.RestoreKeys).split("\n");
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
|
||||
core.debug("Resolved Keys:");
|
||||
core.debug(JSON.stringify(keys));
|
||||
|
||||
|
@ -39,13 +43,6 @@ async function run() {
|
|||
);
|
||||
return;
|
||||
}
|
||||
const regex = /^[^,]*$/;
|
||||
if (!regex.test(key)) {
|
||||
core.setFailed(
|
||||
`Key Validation Error: ${key} cannot contain commas.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue