summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorlitlighilit <litlighilit@foxmail.com>2024-03-04 16:58:33 +0800
committerGitHub <noreply@github.com>2024-03-04 09:58:33 +0100
commit6e875cd7c2b4659f46199593cacf5fced653b660 (patch)
treead1637632af1a27847e636bd21b9761621a8c841 /lib
parent2081da3207b004e21537cf079c8e7f583bc66d76 (diff)
downloadNim-6e875cd7c2b4659f46199593cacf5fced653b660.tar.gz
fix `isAbsolute` broken when `nodejs` on Windows (#23365)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/private/ospaths2.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/private/ospaths2.nim b/lib/std/private/ospaths2.nim
index 5dd09d7e6..a5c0edd9f 100644
--- a/lib/std/private/ospaths2.nim
+++ b/lib/std/private/ospaths2.nim
@@ -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