refactor(browser): share client-actions url helpers

This commit is contained in:
Peter Steinberger
2026-02-15 18:22:10 +00:00
parent 7773c5410b
commit 7ef956d224
4 changed files with 14 additions and 36 deletions

View File

@@ -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 } = {},