Maybe i am making it to hard (and i should just look for a prefix of ./
and ../
) but I don't want to re-invent the wheel and write a function to correctly detect relative paths (for all platforms, etc.)
Existing library?
Are there npm
packages that do this? Surely this problem has been solved...
Approaches?
Barring an existing library, my intended approach was to use the path
module functions to join
the possibly relative path to a known prefix, and then see what the result was, with the assumption that path.join('some_base', possiblyRelative)
would allow some sort of distinguishing characteristic in a platform safe way.
Any other suggestions? Approaches?