library_helpers.ts view source
(url: string, origin?: string): string import {url_to_root_relative} from '@fuzdev/fuz_ui/library_helpers.js'; Convert a full URL to root-relative format by removing the origin.
Uses SvelteKit's page state for the current origin by default.
url
full URL to convert
type
stringorigin
origin to strip (defaults to current page origin)
type
string default
page.url.originreturns
string root-relative URL starting with '/'
examples
// Assuming page.url.origin is 'https://fuz.dev'
url_to_root_relative('https://fuz.dev/docs/api')
// => '/docs/api'