this repo has no description
at main 484 B view raw
1import * as fs from 'node:fs/promises'; 2import * as path from 'node:path'; 3 4export const makeCacheFileHelper = (baseDir: string, ext = '.html') => async (url: URL) => { 5 const { hostname, pathname } = url; 6 const name = pathname.split('/').filter(Boolean).join('_'); 7 const targetDir = path.join(baseDir, hostname); 8 const basename = path.basename(name, path.extname(name)); 9 await fs.mkdir(targetDir, { recursive: true }); 10 return path.join(targetDir, `${basename}${ext}`); 11};