This function has multiple overloads
- Base URL String
- Current Page's URL
- Anchor Elements
Converts any URL source to an absolute, properly encoded URL.Combines a relative URL with a base URL string. Use when you have an explicit base URL string to resolve relative paths against.
Copy
Ask AI
export declare function resolveUrl(input: {
url: string;
baseUrl: string;
}): Promise<string>;
Examples
Copy
Ask AI
import { resolveUrl } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";
interface Params {}
export default async function handler(
params: Params,
page: Page,
context: BrowserContext
) {
// Resolve from base URL string
const absoluteUrl = await resolveUrl({
url: "/lists/table",
baseUrl: "https://sandbox.intuned.dev",
});
// Returns: "https://sandbox.intuned.dev/lists/table"
console.log(absoluteUrl);
return absoluteUrl;
}
Arguments
Converts any URL source to an absolute, properly encoded URL.Uses the current page’s URL as the base URL. Use when resolving URLs relative to the current page.
Copy
Ask AI
export declare function resolveUrl(input: {
url: string;
page: Page;
}): Promise<string>;
Examples
Copy
Ask AI
import { resolveUrl } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";
interface Params {}
export default async function handler(
params: Params,
page: Page,
context: BrowserContext
) {
await page.goto("https://sandbox.intuned.dev/");
// Resolve from the current page's URL
const absoluteUrl = await resolveUrl({
url: "/lists/table",
page: page,
});
// Returns: "https://sandbox.intuned.dev/lists/table"
console.log(absoluteUrl);
return absoluteUrl;
}
Arguments
Converts any URL source to an absolute, properly encoded URL.Extracts the href attribute from a Playwright Locator pointing to an anchor element. Use when extracting and resolving URLs from anchor (
Copy
Ask AI
export declare function resolveUrl(input: { url: Locator }): Promise<string>;
<a>) elements.Examples
Copy
Ask AI
import { resolveUrl } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";
interface Params {}
export default async function handler(
params: Params,
page: Page,
context: BrowserContext
) {
await page.goto("https://sandbox.intuned.dev/");
// Resolve from Anchor Element
const absoluteUrl = await resolveUrl({
url: page.locator("xpath=//a[normalize-space()='Steps Form']"),
});
// Returns: "https://sandbox.intuned.dev/steps-form"
console.log(absoluteUrl);
return absoluteUrl;
}