Skip to content

Commit

Permalink
loadScriptsOnMainThread string[] -> (string | RegExp)[]
Browse files Browse the repository at this point in the history
  • Loading branch information
dymoo committed Dec 26, 2023
1 parent eff7438 commit 3062a96
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/integration/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface PartytownConfig {
get?: GetHook;
globalFns?: string[];
lib?: string;
loadScriptsOnMainThread?: string[];
loadScriptsOnMainThread?: (string | RegExp)[];
logCalls?: boolean;
logGetters?: boolean;
logImageRequests?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export interface PartytownConfig {
* @example loadScriptsOnMainThread:['https://test.com/analytics.js', 'inline-script-id']
* // Loads the `https://test.com/analytics.js` script on the main thread
*/
loadScriptsOnMainThread?: string[];
loadScriptsOnMainThread?: (string | RegExp)[];
get?: GetHook;
set?: SetHook;
apply?: ApplyHook;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/web-worker/worker-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const patchHTMLScriptElement = (WorkerHTMLScriptElement: any, env: WebWor

if (this.type && config.loadScriptsOnMainThread) {
const shouldExecuteScriptViaMainThread = config.loadScriptsOnMainThread.some(
(scriptUrl) => scriptUrl === url
(scriptUrl) => new RegExp(scriptUrl).test(url)
);

if (shouldExecuteScriptViaMainThread) {
Expand Down

0 comments on commit 3062a96

Please sign in to comment.