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
added getPublicUrl feature to key_value_store - fixed linting errors
aarontjdevfe0285792c5c
diff --git a/src/key_value_store.js b/src/key_value_store.jsindex a34d9c198..c235af98f 100644--- a/src/key_value_store.js+++ b/src/key_value_store.js@@ -494,10 +494,12 @@ export class KeyValueStoreLocal {* Retrieves the full public url of the designated file.* @param {String} fileName*/- getPublicUrl(fileName, store_id) {- store_id = store_id ? store_id : 'default';+ getPublicUrl(fileName, storeId) {+ if (!storeId) {+ storeId = 'default';+ }ensureTokenOrLocalStorageEnvExists('key value store');- const publicLocalUrl = `file:/${this.localStoragePath}/${store_id}/${fileName}`;+ const publicLocalUrl = `file:/${this.localStoragePath}/${storeId}/${fileName}`;return publicLocalUrl;}}diff --git a/test/key_value_store.js b/test/key_value_store.jsindex e60e361f3..4a1660c0c 100644--- a/test/key_value_store.js+++ b/test/key_value_store.js@@ -7,7 +7,6 @@ import { KeyValueStoreLocal, KeyValueStore, maybeStringify, getFileNameRegexp, Limport * as utils from '../build/utils';import * as Apify from '../build/index';import { LOCAL_STORAGE_DIR, emptyLocalStorageSubdir, expectDirEmpty, expectDirNonEmpty } from './_helper';-import { doesNotReject } from 'assert';const { apifyClient } = utils;@@ -373,8 +372,7 @@ describe('KeyValueStore', () => {it('should return the local url of a file', () => {process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;const store = new KeyValueStoreLocal('my-store-id', LOCAL_STORAGE_DIR);-- expect(store.getPublicUrl('file','my-store-id')).to.equal(`file:/${store.localStoragePath}/my-store-id/file`);+ expect(store.getPublicUrl('file', 'my-store-id')).to.equal(`file:/${store.localStoragePath}/my-store-id/file`);delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];});@@ -385,7 +383,6 @@ describe('KeyValueStore', () => {expect(store.getPublicUrl('file')).to.equal(`${publicUrl}/my-store-id/records/file`);delete process.env[ENV_VARS.TOKEN];-});});@@ -473,4 +470,4 @@ describe('KeyValueStore', () => {expectDirEmpty(storeDir);});});-});\ No newline at end of file+});