internalURL
Resolve a same-origin URL.
Compatibility
ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
Import from @kasperrt/smolter/utils
Signature
function internalURL(base: string, href = base): URL | undefined;Parameters
base is an absolute URL string. href defaults to base and is resolved with the URL constructor.
Returns
A URL if its origin matches base, otherwise undefined.
Usage
Import this API from one of the entry points listed above. Keep server and build helpers in their dedicated subpaths.
const url = internalURL("https://example.com/tasks", "/tasks/1");Behavior and edge cases
This low-level core helper does not navigate or validate route registration. Invalid URL syntax can throw. Different protocols or ports produce a different origin and are rejected.