Skip to content

Commit

Permalink
fix isAbsolute broken when nodejs on Windows (#23365)
Browse files Browse the repository at this point in the history
When target is nodejs, 
`isAbsolute` used to only check in the POSIX flavor,

i.e.  for js backend on Windows, 
```nim
isAbsolute(r"C:\Windows") == false
```

This fixes it.
  • Loading branch information
litlighilit authored Mar 4, 2024
1 parent 2081da3 commit 6e875cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/std/private/ospaths2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ proc isAbsolute*(path: string): bool {.rtl, noSideEffect, extern: "nos$1", raise
result = path[0] != ':'
elif defined(RISCOS):
result = path[0] == '$'
elif defined(posix) or defined(js):
# `or defined(js)` wouldn't be needed pending https://github.com/nim-lang/Nim/issues/13469
# This works around the problem for posix, but Windows is still broken with nim js -d:nodejs
elif defined(posix):
result = path[0] == '/'
elif defined(nodejs):
{.emit: [result," = require(\"path\").isAbsolute(",path.cstring,");"].}
else:
raiseAssert "unreachable" # if ever hits here, adapt as needed

Expand Down

0 comments on commit 6e875cd

Please sign in to comment.