|
67 | 67 | return depth > 0 ? "../".repeat(depth) : "./"; |
68 | 68 | } |
69 | 69 |
|
| 70 | +// function getRelativePath(path) { |
| 71 | +// const isBrowser = typeof window !== 'undefined'; |
| 72 | + |
| 73 | +// // If no path provided, use window.location.pathname |
| 74 | +// if (!path && isBrowser) { |
| 75 | +// path = window.location.pathname; |
| 76 | + |
| 77 | +// // FIX: Only remove the end segment if it looks like a file (has an extension like .html) |
| 78 | +// // This prevents stripping valid routes like /dashboard |
| 79 | +// if (/\.[^/]+$/.test(path)) { |
| 80 | +// path = path.replace(/\/[^\/]*$/, ""); |
| 81 | +// } |
| 82 | +// } |
| 83 | + |
| 84 | +// // For localhost/127.0.0.1, remove everything up to and including the first '/src' |
| 85 | +// if ( |
| 86 | +// isBrowser && |
| 87 | +// (window.location.hostname === "localhost" || |
| 88 | +// window.location.hostname === "127.0.0.1") |
| 89 | +// ) { |
| 90 | +// const srcIndex = path.indexOf("/src"); |
| 91 | +// if (srcIndex !== -1) { |
| 92 | +// // If path is "/BeautySalon/src", this returns "" |
| 93 | +// path = path.slice(srcIndex + 4); |
| 94 | +// } |
| 95 | +// } |
| 96 | + |
| 97 | +// // Handle the empty string case here: |
| 98 | +// // "" does not end with "/", so it adds one -> "/" |
| 99 | +// if (!path || !path.endsWith("/")) { |
| 100 | +// path = (path || "") + "/"; |
| 101 | +// } |
| 102 | + |
| 103 | +// // "/" splits to ['', ''], filter removes them -> length is 0 |
| 104 | +// let depth = path.split("/").filter(Boolean).length; |
| 105 | + |
| 106 | +// // 0 depth returns "./" |
| 107 | +// return depth > 0 ? "../".repeat(depth) : "./"; |
| 108 | +// } |
| 109 | + |
70 | 110 | /** |
71 | 111 | * Generates an ObjectId |
72 | 112 | */ |
|
0 commit comments