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 786ed1b commit cd0b369Copy full SHA for cd0b369
src/index.js
@@ -41,9 +41,23 @@
41
}
42
43
function getRelativePath(path) {
44
+ // If no path provided, use window.location.pathname
45
if (!path && isBrowser) {
46
path = window.location.pathname.replace(/\/[^\/]*$/, ""); // Remove file from path
47
48
+
49
+ // For localhost/127.0.0.1, trim everything after '/src'
50
+ if (
51
+ isBrowser &&
52
+ (location.hostname === "localhost" ||
53
+ location.hostname === "127.0.0.1")
54
+ ) {
55
+ const srcIndex = path.indexOf("/src");
56
+ if (srcIndex !== -1) {
57
+ path = path.substring(0, srcIndex + 4); // keep '/src'
58
+ }
59
60
61
if (!path.endsWith("/")) {
62
path += "/";
63
@@ -1281,4 +1295,4 @@
1281
1295
setAttributeNames,
1282
1296
getAttributeNames
1283
1297
};
1284
-});
1298
+});
0 commit comments