Skip to content
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

Unix socket is expected to be encoded with %2F #1767

Open
3 tasks done
ghost opened this issue May 11, 2023 · 0 comments
Open
3 tasks done

Unix socket is expected to be encoded with %2F #1767

ghost opened this issue May 11, 2023 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented May 11, 2023

Describe the bug

Node.js version:
18.15.0

OS version:
Ubuntu 20.4

Superagent version:
8.0.9

Description:
As we can see from line 728 of src/node/index.js superagent expects a unix socket address like /path/to/socket.sock to be formatted as %2Fpath%2Fto%2Fsocket.sock, to then separate the socket path from the actual url with a regular expression.

If the unix path is not formatted as required, an unclear error will be thrown:
Cannot read properties of null (reading '1')
which is caused by the regexr not being able to match the unix socket path.

Code to reproduce

await superagent .get('http+unix:///path/to/socket.sock/the/actual/url');

// will throw: Cannot read properties of null (reading '1')

It would be much easier to just skip this whole pattern matching and provide and option to directly pass the socket path.

await superagent.get('http://the/actual/url').socket('/path/to/socket.sock')

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@ghost ghost added the Bug label May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants