Skip to content

Commit 11da852

Browse files
authored
Compare case-insenitively for full cache key match (#303)
Some self-hosted (or otherwise non-github-hosted) runners are non-case-preserving for cache keys. To support such configurations, set the `cache-hit` output variable to `true` if the found cache key matches case-insenitively. Fixes: #302
1 parent 5e4a767 commit 11da852

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

dist/restore/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151483,7 +151483,9 @@ async function run() {
151483151483
lookupOnly,
151484151484
});
151485151485
if (restoreKey) {
151486-
const match = restoreKey === key;
151486+
const match = restoreKey.localeCompare(key, undefined, {
151487+
sensitivity: "accent"
151488+
}) === 0;
151487151489
lib_core.info(`${lookupOnly ? "Found" : "Restored from"} cache key "${restoreKey}" full match: ${match}.`);
151488151490
if (!match) {
151489151491
// pre-clean the target directory on cache mismatch

src/restore.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ async function run() {
4242
lookupOnly,
4343
});
4444
if (restoreKey) {
45-
const match = restoreKey === key;
45+
const match = restoreKey.localeCompare(key, undefined, {
46+
sensitivity: "accent"
47+
}) === 0;
4648
core.info(`${lookupOnly ? "Found" : "Restored from"} cache key "${restoreKey}" full match: ${match}.`);
4749
if (!match) {
4850
// pre-clean the target directory on cache mismatch

0 commit comments

Comments
 (0)