> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# resolveUrl

<Info>This function has multiple overloads</Info>

<Tabs>
  <Tab title="Base URL String">
    Converts any URL source to an absolute, properly encoded URL.

    ```typescript theme={null}
    export declare function resolveUrl(input: {
      url: string;
      baseUrl: string;
    }): Promise<string>;
    ```

    Combines a relative URL with a base URL string. Use when you have an explicit base URL string to resolve relative paths against.

    ## Examples

    <CodeGroup>
      ```typescript Resolve from Base URL String theme={null}
      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;
      }
      ```
    </CodeGroup>

    ## Arguments

    <ResponseField name="input" type="Object" required>
      Configuration object with different properties based on the overload

      <Expandable title="properties" defaultOpen>
        <ResponseField name="input.url" type="string" required>
          The relative or absolute URL to resolve
        </ResponseField>

        <ResponseField name="input.baseUrl" type="string" required>
          Base URL string to resolve relative URLs against
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Tab>

  <Tab title="Current Page's URL">
    Converts any URL source to an absolute, properly encoded URL.

    ```typescript theme={null}
    export declare function resolveUrl(input: {
      url: string;
      page: Page;
    }): Promise<string>;
    ```

    Uses the current page's URL as the base URL. Use when resolving URLs relative to the current page.

    ## Examples

    <CodeGroup>
      ```typescript Resolve from the Current Page's URL theme={null}
      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;
      }
      ```
    </CodeGroup>

    ## Arguments

    <ResponseField name="input" type="Object" required>
      Configuration object with different properties based on the overload

      <Expandable title="properties" defaultOpen>
        <ResponseField name="input.url" type="string" required>
          The relative or absolute URL to resolve
        </ResponseField>

        <ResponseField name="input.page" type="Page" required>
          Playwright Page object to extract base URL from. The current page URL will be used as the base URL
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Tab>

  <Tab title="Anchor Elements">
    Converts any URL source to an absolute, properly encoded URL.

    ```typescript theme={null}
    export declare function resolveUrl(input: { url: Locator }): Promise<string>;
    ```

    Extracts the href attribute from a Playwright Locator pointing to an anchor element. Use when extracting and resolving URLs from anchor (`<a>`) elements.

    ## Examples

    <CodeGroup>
      ```typescript Resolve from Anchor Element theme={null}
      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;
      }
      ```
    </CodeGroup>

    ## Arguments

    <ResponseField name="input" type="Object" required>
      Configuration object with different properties based on the overload

      <Expandable title="properties" defaultOpen>
        <ResponseField name="input.url" type="Locator" required>
          Playwright Locator pointing to an anchor element. The href attribute will be extracted and resolved relative to the current page.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Tab>
</Tabs>

## Returns: `Promise<string>`

Promise that resolves to the absolute, properly encoded URL string
