Skip to content

Handle Absolute JAR Path #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

BrendanC23
Copy link

This PR enables an absolute path to be passed as the jar parameter. It resolves #104. A new test (that previously would have failed) has been added.

Now, this code works:

const java = new JavaCaller({
    jar: "F:\\my-path\\file.jar",
});

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG.md listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

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.
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.
@nvuillam
Copy link
Owner

@BrendanC23 the test class is failing, please can you have a look ?

image

nvuillam and others added 2 commits February 23, 2025 10:17
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:\\"`.
@BrendanC23
Copy link
Author

@nvuillam I made some changes to the PR. There is one test that is failing due to a timeout.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Absolute jar path
2 participants