mdfetch API Documentation - v1.0.0
    Preparing search index...

    Function convertToAbsoluteURL

    • Converts a relative URL to an absolute URL.

      Handles various URL formats:

      • Relative paths: /pathhttps://example.com/path
      • Parent directories: ../path → resolves correctly
      • Protocol-relative: //cdn.com/filehttps://cdn.com/file
      • Already absolute URLs are returned unchanged

      Parameters

      • base: string

        The base URL to resolve against

      • relativePath: string

        The relative or absolute path to convert

      Returns string

      The absolute URL

      convertToAbsoluteURL('https://example.com/page', '/images/pic.jpg')
      // Returns: 'https://example.com/images/pic.jpg'

      convertToAbsoluteURL('https://example.com/dir/', '../file.html')
      // Returns: 'https://example.com/file.html'