We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45bcd17 commit bf4edf9Copy full SHA for bf4edf9
lib/util/url.ts
@@ -45,7 +45,17 @@ export function resolve(from: string, to: string) {
45
*/
46
export function cwd() {
47
if (typeof window !== "undefined" && window.location && window.location.href) {
48
- return window.location.href;
+ const href = window.location.href;
49
+ if (!href || !href.startsWith("http")) {
50
+ // try parsing as url, and if it fails, return root url /
51
+ try {
52
+ new URL(href);
53
+ return href;
54
+ } catch {
55
+ return "/";
56
+ }
57
58
59
}
60
61
if (typeof process !== "undefined" && process.cwd) {
0 commit comments