Skip to content

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

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions