UNPKG

@jsenv/util

Version:

Set of functions often needed when using Node.js.

17 lines (13 loc) 393 B
export const urlIsInsideOf = (urlValue, otherUrlValue) => { const url = new URL(urlValue) const otherUrl = new URL(otherUrlValue) if (url.origin !== otherUrl.origin) { return false } const urlPathname = url.pathname const otherUrlPathname = otherUrl.pathname if (urlPathname === otherUrlPathname) { return false } return urlPathname.startsWith(otherUrlPathname) }