Hiyve Components - v1.0.0
    Preparing search index...
    • Turn what a person typed into a safe absolute URL, or null.

      Parameters

      • raw: string

      Returns string | null

      A bare example.com becomes https://example.com/; javascript:, data: and every other scheme outside http/https/mailto/tel never pass. The result is the URL as the browser normalises it (a trailing slash is added to a bare origin).

      normalizeLinkHref('example.com/a');        // 'https://example.com/a'
      normalizeLinkHref('javascript:alert(1)'); // null
      normalizeLinkHref(' '); // null