UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

31 lines (30 loc) 1.06 kB
function hasUrlProtocolPrefix(href) { return /^[\w\d_+.-]+:\/\//.test(href); } function isWellKnownUri(href) { return /^(https?|mailto|tel|sms|geo|maps|market|itmss?|itms-apps|content|file):/.test(href); } function shouldLinkExternally(href) { return !/^[./]/.test(href) && (hasUrlProtocolPrefix(href) || isWellKnownUri(href)); } var staticFileExtensionRegex = /\.(?:[a-z0-9]{2,5}|webmanifest|wasm|woff2)$/i; function hasFileExtension(href) { if (!href) return false; try { var url = new URL(href, "http://localhost"); if (url.protocol !== "http:" && url.protocol !== "https:") { return true; } return staticFileExtensionRegex.test(url.pathname); } catch (unused) { return false; } } function shouldPreloadRoute(href) { if (!href || href[0] === "#") return false; if (shouldLinkExternally(href)) return false; if (hasFileExtension(href)) return false; return true; } export { hasFileExtension, hasUrlProtocolPrefix, isWellKnownUri, shouldLinkExternally, shouldPreloadRoute }; //# sourceMappingURL=url.native.js.map