Closed rulatir closed 3 years ago
isSubdir already works as isSubdirOrSame
Thanks for a prompt response. I revised my request.
I'd probably name it isSubdirStrict
or maybe we can make a breaking change and add isSubdirOrSame
Did a preliminary PR subject to further commits, but really all the work is in deciding how to name things.
The solution I propose makes it possible to access the new API without modifying the import/require statement. I add the reference to the new function as a property of the old function. Usage:
const isSubdir = require('is-subdir');
if (isSubdir.proper(dir1, dir2)) {
//...
}
Rename to strict
?
ok
A sec to update README.md and tests...
PR ready with updated test, README.md and is-subdir/index.d.ts
.
ok, but you need to submit the PR to this repo
Oops. Making this mistake every. Goddamn. Time.
published
[edited to revise the request in light of correct understanding of the current behavior]
As per title, please implement
isProperSubdir()
which would only returntrue
if the second parameter is a proper subdirectory of the first but not the same. This should be in the library because it should use the same path normalization/resolution strategy as the original function.Alternatively we could add an optional boolean third argument to turn on the
!==
check, defaulting tofalse
.Implementation should be trivial and I could submit a PR, but please decide on the API variant.