WIndows works perfectly

This commit is contained in:
Cris Stringfellow 2024-08-29 16:00:23 +00:00
parent d91a1856b7
commit dac4145195
No known key found for this signature in database
1 changed files with 32 additions and 21 deletions

View File

@ -177,6 +177,7 @@
]);
const NEVER_CACHE = new Set([
`${GO_SECURE ? 'https://localhost' : 'http://127.0.0.1'}:${args.server_port}`,
`http://localhost:${args.server_port}`,
`http://localhost:${args.chrome_port}`,
`http://127.0.0.1:${args.chrome_port}`,
`https://127.0.0.1:${args.chrome_port}`,
@ -776,29 +777,39 @@
}
async function saveResponseData(key, url, response) {
const origin = (new URL(url).origin);
let originDir = State.Cache.get(origin);
originDir = originDir.replace(TBL, '_');
if ( ! originDir ) {
originDir = Path.resolve(library_path(), origin.replace(TBL, '_'));
try {
Fs.mkdirSync(originDir, {recursive:true});
} catch(e) {
console.warn(`Issue with origin directory ${originDir}`, e);
}
State.Cache.set(origin, originDir);
}
const fileName = `${await sha1(key)}.json`;
const responsePath = Path.resolve(originDir, fileName);
try {
await Fs.promises.writeFile(responsePath, JSON.stringify(response,null,2));
} catch(e) {
console.warn(`Issue with origin directory or file: ${responsePath}`, e);
}
const origin = (new URL(url).origin);
let originDir = State.Cache.get(origin);
if ( ! originDir ) {
originDir = Path.resolve(library_path(), origin.replace(TBL, '_'));
try {
Fs.mkdirSync(originDir, {recursive:true});
} catch(e) {
console.warn(`Issue with origin directory ${originDir}`, e);
}
State.Cache.set(origin, originDir);
} else {
if ( originDir.includes(':\\\\') ) {
originDir = originDir.split(/:\\\\/, 2);
originDir[1] = originDir[1]?.replace?.(TBL, '_');
originDir = originDir.join(':\\\\');
}
}
return responsePath;
const fileName = `${await sha1(key)}.json`;
const responsePath = Path.resolve(originDir, fileName);
try {
await Fs.promises.writeFile(responsePath, JSON.stringify(response,null,2));
} catch(e) {
console.warn(`Issue with origin directory or file: ${responsePath}`, e);
}
return responsePath;
} catch(e) {
console.warn(`Could not save response data`, e);
return '';
}
}
async function sha1(key) {