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 0b60b3a commit 3de416dCopy full SHA for 3de416d
lib/util/url.ts
@@ -44,18 +44,21 @@ export function resolve(from: string, to: string) {
44
* @returns
45
*/
46
export function cwd() {
47
- if (typeof window !== "undefined") {
+ if (typeof window !== "undefined" && window.location) {
48
return location.href;
49
}
50
51
- const path = process.cwd();
+ if (typeof process !== "undefined" && process.cwd) {
52
+ const path = process.cwd();
53
- const lastChar = path.slice(-1);
54
- if (lastChar === "/" || lastChar === "\\") {
55
- return path;
56
- } else {
57
- return path + "/";
+ const lastChar = path.slice(-1);
+ if (lastChar === "/" || lastChar === "\\") {
+ return path;
+ } else {
58
+ return path + "/";
59
+ }
60
61
+ return "/";
62
63
64
/**
0 commit comments