diff --git a/src/browser/client-actions-core.ts b/src/browser/client-actions-core.ts index c3d17922c6..cce39c03e2 100644 --- a/src/browser/client-actions-core.ts +++ b/src/browser/client-actions-core.ts @@ -3,20 +3,9 @@ import type { BrowserActionPathResult, BrowserActionTabResult, } from "./client-actions-types.js"; +import { buildProfileQuery, withBaseUrl } from "./client-actions-url.js"; import { fetchBrowserJson } from "./client-fetch.js"; -function buildProfileQuery(profile?: string): string { - return profile ? `?profile=${encodeURIComponent(profile)}` : ""; -} - -function withBaseUrl(baseUrl: string | undefined, path: string): string { - const trimmed = baseUrl?.trim(); - if (!trimmed) { - return path; - } - return `${trimmed.replace(/\/$/, "")}${path}`; -} - export type BrowserFormField = { ref: string; type: string; diff --git a/src/browser/client-actions-observe.ts b/src/browser/client-actions-observe.ts index 13ac92b05b..6cc68541c2 100644 --- a/src/browser/client-actions-observe.ts +++ b/src/browser/client-actions-observe.ts @@ -4,20 +4,9 @@ import type { BrowserNetworkRequest, BrowserPageError, } from "./pw-session.js"; +import { buildProfileQuery, withBaseUrl } from "./client-actions-url.js"; import { fetchBrowserJson } from "./client-fetch.js"; -function buildProfileQuery(profile?: string): string { - return profile ? `?profile=${encodeURIComponent(profile)}` : ""; -} - -function withBaseUrl(baseUrl: string | undefined, path: string): string { - const trimmed = baseUrl?.trim(); - if (!trimmed) { - return path; - } - return `${trimmed.replace(/\/$/, "")}${path}`; -} - export async function browserConsoleMessages( baseUrl: string | undefined, opts: { level?: string; targetId?: string; profile?: string } = {}, diff --git a/src/browser/client-actions-state.ts b/src/browser/client-actions-state.ts index b2f351b33d..ad04b652c7 100644 --- a/src/browser/client-actions-state.ts +++ b/src/browser/client-actions-state.ts @@ -1,18 +1,7 @@ import type { BrowserActionOk, BrowserActionTargetOk } from "./client-actions-types.js"; +import { buildProfileQuery, withBaseUrl } from "./client-actions-url.js"; import { fetchBrowserJson } from "./client-fetch.js"; -function buildProfileQuery(profile?: string): string { - return profile ? `?profile=${encodeURIComponent(profile)}` : ""; -} - -function withBaseUrl(baseUrl: string | undefined, path: string): string { - const trimmed = baseUrl?.trim(); - if (!trimmed) { - return path; - } - return `${trimmed.replace(/\/$/, "")}${path}`; -} - export async function browserCookies( baseUrl: string | undefined, opts: { targetId?: string; profile?: string } = {}, diff --git a/src/browser/client-actions-url.ts b/src/browser/client-actions-url.ts new file mode 100644 index 0000000000..25c47fa6db --- /dev/null +++ b/src/browser/client-actions-url.ts @@ -0,0 +1,11 @@ +export function buildProfileQuery(profile?: string): string { + return profile ? `?profile=${encodeURIComponent(profile)}` : ""; +} + +export function withBaseUrl(baseUrl: string | undefined, path: string): string { + const trimmed = baseUrl?.trim(); + if (!trimmed) { + return path; + } + return `${trimmed.replace(/\/$/, "")}${path}`; +}