(url, segment = "app")
| 235 | * @returns {string} - The URL with the trailing segment removed, or unmodified if it didn’t match. |
| 236 | */ |
| 237 | export function removeTrailingSegment(url, segment = "app") { |
| 238 | // Normalize a trailing slash (e.g. “/app/” → “/app”) |
| 239 | const normalized = url.endsWith("/") ? url.slice(0, -1) : url; |
| 240 | |
| 241 | const lastSlash = normalized.lastIndexOf("/"); |
| 242 | const lastPart = normalized.slice(lastSlash + 1); |
| 243 | |
| 244 | if (lastPart === segment) { |
| 245 | return normalized.slice(0, lastSlash); |
| 246 | } |
| 247 | |
| 248 | return normalized; |
| 249 | } |
| 250 | |
| 251 | export const color = [ |
| 252 | "#93a3db", |
no outgoing calls
no test coverage detected