Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ladjs/superagent
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v10.1.1
Choose a base ref
...
head repository: ladjs/superagent
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v10.2.0
Choose a head ref
  • 10 commits
  • 6 files changed
  • 2 contributors

Commits on May 13, 2024

  1. fix: ipv6 addresses parsing

    perrin4869 committed May 13, 2024

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    muesli Christian Muehlhaeuser
    Copy the full SHA
    ec50f5a View commit details

Commits on Jun 11, 2024

  1. remove regression test

    perrin4869 committed Jun 11, 2024
    Copy the full SHA
    15e9de6 View commit details
  2. re-add test

    perrin4869 committed Jun 11, 2024
    Copy the full SHA
    10a2e40 View commit details
  3. attempt support ipv6

    perrin4869 committed Jun 11, 2024
    Copy the full SHA
    a2f11f8 View commit details
  4. attempt support ipv6

    perrin4869 committed Jun 11, 2024
    Copy the full SHA
    d688596 View commit details
  5. fix?

    perrin4869 committed Jun 11, 2024
    Copy the full SHA
    07954a1 View commit details

Commits on Mar 10, 2025

  1. Merge pull request #1805 from perrin4869/fix/ipv6-addresses

    fix: ipv6 addresses parsing
    titanism authored Mar 10, 2025
    Copy the full SHA
    150eb6c View commit details
  2. fix(https2): ipv6 addresses url

    fix
    
    oops
    perrin4869 committed Mar 10, 2025
    Copy the full SHA
    e29fd25 View commit details
  3. Merge pull request #1829 from perrin4869/fix/http2/ipv6-addresses

    fix(https2): ipv6 addresses url
    titanism authored Mar 10, 2025
    Copy the full SHA
    02cad6a View commit details
  4. 10.2.0

    titanism committed Mar 10, 2025
    Copy the full SHA
    e38f4eb View commit details
Showing with 31 additions and 4 deletions.
  1. +1 −0 .dist.eslintrc
  2. +1 −1 package.json
  3. +7 −2 src/node/http2wrapper.js
  4. +1 −1 src/node/index.js
  5. +5 −0 src/utils.js
  6. +16 −0 test/node/basic.js
1 change: 1 addition & 0 deletions .dist.eslintrc
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
"no-undef": "off",
"no-unused-vars": "off",
"no-useless-escape": "off",
"no-obj-calls": "off",
"no-cond-assign": "off",
"no-redeclare": "off",
"node/no-exports-assign": "off",
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "superagent",
"description": "elegant & feature rich browser / node HTTP with a fluent API",
"version": "10.1.1",
"version": "10.2.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"browser": {
"./src/node/index.js": "./src/client.js",
9 changes: 7 additions & 2 deletions src/node/http2wrapper.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,10 @@ function setProtocol(protocol) {
};
}

function normalizeIpv6Host(host) {
return net.isIP(host) === 6 ? `[${host}]` : host;
}

class Request extends Stream {
constructor(protocol, options) {
super();
@@ -48,11 +52,12 @@ class Request extends Stream {

this._headers = {};

const normalizedHost = normalizeIpv6Host(host);
const session = http2.connect(
`${protocol}//${host}:${port}`,
`${protocol}//${normalizedHost}:${port}`,
sessionOptions
);
this.setHeader('host', `${host}:${port}`);
this.setHeader('host', `${normalizedHost}:${port}`);

session.on('error', (error) => this.emit('error', error));

2 changes: 1 addition & 1 deletion src/node/index.js
Original file line number Diff line number Diff line change
@@ -754,7 +754,7 @@ Request.prototype.request = function () {
options.method = this.method;
options.port = url.port;
options.path = path;
options.host = url.hostname;
options.host = utils.normalizeHostname(url.hostname); // ex: [::1] -> ::1
options.ca = this._ca;
options.key = this._key;
options.pfx = this._pfx;
5 changes: 5 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -72,6 +72,11 @@ exports.cleanHeader = (header, changesOrigin) => {
return header;
};

exports.normalizeHostname = (hostname) => {
const [,normalized] = hostname.match(/^\[([^\]]+)\]$/) || [];
return normalized || hostname;
};

/**
* Check if `obj` is an object.
*
16 changes: 16 additions & 0 deletions test/node/basic.js
Original file line number Diff line number Diff line change
@@ -134,6 +134,22 @@ describe('[node] request', () => {
});
});

describe('ipv6 address', () => {
it('should successfully query an ipv6 address', (done) => {
request.get(`http://[::]:${process.env.ZUUL_PORT}/url?a=(b%29`).end((error, res) => {
assert.equal('/url?a=(b%29', res.text);
done();
});
});

it('should successfully query an ipv6 address', (done) => {
request.get(`http://[::1]:${process.env.ZUUL_PORT}/url?a=(b%29`).end((error, res) => {
assert.equal('/url?a=(b%29', res.text);
done();
});
});
});

describe('.buffer()', () => {
it('should enable buffering', (done) => {
request