UNPKG

one

Version:

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

63 lines (61 loc) 2.09 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var url_exports = {}; __export(url_exports, { hasFileExtension: () => hasFileExtension, hasUrlProtocolPrefix: () => hasUrlProtocolPrefix, isWellKnownUri: () => isWellKnownUri, shouldLinkExternally: () => shouldLinkExternally, shouldPreloadRoute: () => shouldPreloadRoute }); module.exports = __toCommonJS(url_exports); 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; } //# sourceMappingURL=url.native.js.map