mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
fix some url rewriters
This commit is contained in:
parent
39f11ef812
commit
f53bc623ff
3 changed files with 3 additions and 18 deletions
|
@ -12,7 +12,6 @@ import "./storage.ts";
|
|||
import "./css.ts";
|
||||
import "./history.ts";
|
||||
import "./worker.ts";
|
||||
import "./url.ts";
|
||||
import "./beacon.ts"
|
||||
|
||||
declare global {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { encodeUrl } from "../shared/rewriters/url";
|
||||
export const URL = globalThis.URL;
|
||||
|
||||
if (globalThis.window) {
|
||||
window.URL = new Proxy(URL, {
|
||||
construct(target, argArray, newTarget) {
|
||||
if (typeof argArray[0] === "string") argArray[0] = encodeUrl(argArray[0]);
|
||||
if (typeof argArray[1] === "string") argArray[1] = encodeUrl(argArray[1]);
|
||||
|
||||
return Reflect.construct(target, argArray, newTarget);
|
||||
},
|
||||
});
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
import { URL } from "../../client/url";
|
||||
import { rewriteJs } from "./js";
|
||||
;import { rewriteJs } from "./js";
|
||||
|
||||
function canParseUrl(url: string, origin?: URL) {
|
||||
try {
|
||||
|
@ -14,7 +13,7 @@ function canParseUrl(url: string, origin?: URL) {
|
|||
// something is broken with this but i didn't debug it
|
||||
export function encodeUrl(url: string | URL, origin?: URL) {
|
||||
if (url instanceof URL) {
|
||||
return url.toString();
|
||||
url = url.href;
|
||||
}
|
||||
|
||||
if (!origin) {
|
||||
|
@ -46,7 +45,7 @@ export function encodeUrl(url: string | URL, origin?: URL) {
|
|||
// something is also broken with this but i didn't debug it
|
||||
export function decodeUrl(url: string | URL) {
|
||||
if (url instanceof URL) {
|
||||
return url.toString();
|
||||
url = url.href;
|
||||
}
|
||||
|
||||
if (/^(#|about|data|mailto|javascript)/.test(url)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue