Skip to content

Commit

Permalink
chore(fetchDevel): URL validation (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Feb 10, 2021
1 parent 76f0b0b commit f997450
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/fetchDevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ async function fetchDevel(url, fetchOptions) {
}
}

if (contentObj.request.url !== url && !filename.match(/\.fake\.json$/)) {
const message = "URL mismatch - did you want to delete stale cached " +
"result or rename to .fake.json?\n\n" +
" Requested URL: " + url + "\n" +
" Cached URL: " + contentObj.request.url + "\n" +
"\n" +
"File: " + filename;
throw new Error(message)
}

const res = cache[filename] = new FakeResponse(contentObj.response);
return res;
}
Expand Down

0 comments on commit f997450

Please sign in to comment.