Skip to content

Commit

Permalink
fix: Setup globalThis.location & support class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Jun 27, 2024
1 parent 00b1cd9 commit 4f69f96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ export default async function prerender(vnode, options) {
* @param {string} path - current URL path
*/
export function locationStub(path) {
globalThis.location = {};
const u = new URL(path, 'http://localhost');
for (const i in u) {
try {
globalThis.location[i] = String(u[i]);
globalThis.location[i] = /to[A-Z]/.test(i)
? u[i].bind(u)
: String(u[i]);
} catch {}
}
}

0 comments on commit 4f69f96

Please sign in to comment.