MCPcopy Create free account
hub / github.com/itwanger/toBeBetterJavaer / shouldProcessUrl

Function shouldProcessUrl

scripts/convert-mdnice-images-to-cdn.js:259–272  ·  view source on GitHub ↗
(url, domains)

Source from the content-addressed store, hash-verified

257}
258
259function shouldProcessUrl(url, domains) {
260 let parsed;
261 try {
262 parsed = new URL(url);
263 } catch {
264 return false;
265 }
266
267 if (!domains.some((domain) => hostMatches(parsed.hostname, domain))) {
268 return false;
269 }
270
271 return IMAGE_EXTENSIONS.has(path.extname(parsed.pathname).toLowerCase());
272}
273
274function hostMatches(hostname, domain) {
275 return hostname === domain || hostname.endsWith(`.${domain}`);

Callers 1

findImageUrlsFunction · 0.85

Calls 1

hostMatchesFunction · 0.85

Tested by

no test coverage detected