Commit 0009dbc
Handle Absolute JAR Path (#106)
* Handle absolute paths to JAR file
This commit fixes instances where the `jar` parameter is an absolute
path to the JAR file. Previously, the path for
```js
const java = new JavaCaller({
jar: "F:\\my-path\\file.jar",
});
```
would become `./F:\\my-path\\file.jar`. Now, it is kept as-is, allowing
absolute paths to be provided.
* Handle absolute paths to JAR file
This commit fixes instances where the `jar` parameter is an absolute
path to the JAR file. Previously, the path for
```js
const java = new JavaCaller({
jar: "F:\\my-path\\file.jar",
});
```
would become `./F:\\my-path\\file.jar`. Now, it is kept as-is, allowing
absolute paths to be provided.
* Fix handling of absolute paths
This commit fixes the handling of absolute paths, switching from
`path.join()` to `path.isAbsolute()` to handle differing behavior for
different platforms.
`path.join()` works differently for Windows paths and Linux paths.
`path.join(".", "C:\\") === "C:\\"`
`path.join(".", "/home/test") === "home/test"`
The latter is missing a leading `/` and thus is no longer an
absolute path.
As described in [this issue](GHSA-37v4-cwgp-x353),
there was a NodeJS [security vulnerability](https://nodejs.org/en/blog/vulnerability/january-2025-security-releases)
that caused the behavior of `path.join()` to be changed. Newer versions
of Node will return a relative path in these instances, so
`path.join(".", "C:\\") === ".\\C:\\"`.
---------
Co-authored-by: Nicolas Vuillamy <nicolas.vuillamy@gmail.com>1 parent fb429b7 commit 0009dbc
3 files changed
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | | - | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
178 | 190 | | |
0 commit comments