Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Add regex factory
Ondra Urban3778cc116169
diff --git a/src/key_value_store.js b/src/key_value_store.jsindex 08cde511d..36d9bc839 100644--- a/src/key_value_store.js+++ b/src/key_value_store.js@@ -182,6 +182,14 @@ export class KeyValueStore {}}+/**+ * Helper to create a file-matching RegExp from a KeyValueStore key.+ * @param key+ * @returns {RegExp}+ * @ignore+ */+const getFileNameRegex = key => new RegExp(`^${key}\\.[a-z0-9]+$`);+/*** This is a local representation of a key-value store.*@@ -203,7 +211,7 @@ export class KeyValueStoreLocal {return this.initializationPromise.then(() => readdirPromised(this.localEmulationPath)).then((files) => {- const regex = new RegExp(`^${key}\\.[a-z0-9]+$`);+ const regex = getFileNameRegex(key);const fileName = files.find(file => regex.test(file));if (fileName) {const filePath = path.resolve(this.localEmulationPath, fileName);@@ -229,7 +237,7 @@ export class KeyValueStoreLocal {const deletePromise = readdirPromised(this.localEmulationPath).then((files) => {- const regex = new RegExp(`^${key}\\.[a-z0-9]+$`);+ const regex = getFileNameRegex(key);const fileName = files.find(file => regex.test(file));return fileName ? unlinkPromised(getPath(fileName)) : Promise.resolve();});