Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Parsing litteral IPv6 addresses in URLs (RFC2732 support) #1138

Closed
shimaore opened this issue Jun 2, 2011 · 4 comments
Closed

Parsing litteral IPv6 addresses in URLs (RFC2732 support) #1138

shimaore opened this issue Jun 2, 2011 · 4 comments
Labels

Comments

@shimaore
Copy link

shimaore commented Jun 2, 2011

It appears that url.js does not know how to parse litteral IPv6 addresses in URLs (RFC2732).

The RFC gives the following examples:

  http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
  http://[1080:0:0:0:8:800:200C:417A]/index.html
  http://[3ffe:2a00:100:7031::1]
  http://[1080::8:800:200C:417A]/foo
  http://[::192.9.5.5]/ipng
  http://[::FFFF:129.144.52.38]:80/index.html
  http://[2010:836B:4179::836B:4179]

In node.js these will be parsed with the IPv6 address ending up in the pathname field.

@isaacs
Copy link

isaacs commented Jun 2, 2011

Yeah, I've been putting this off until someone asks for it.

It seems like the only change is that a hostname can be /^\[[a-fA-F0-9:.]+\]$/, right? The issue, of course, is that node's http client doesn't know how to request to hosts like that, does it?

@shimaore
Copy link
Author

shimaore commented Jun 2, 2011

Actually the hostname is only the part between the brackets (=the IPv6 address); node is OK with those (e.g. http.request() gets host and port separately, and works with host = IPv6 address).

The host field is the one that needs the brackets to differentiate between the IPv6 address and the port.

href: 'http://user:pass@[::1]:8080/p/a/t/h?query=string#hash'
host: 'user:pass@[::1]:8080'
hostname: '::1'

parseHost() needs to check for brackets and remove them before assigning to out.hostname.
urlFormat() needs to add brackets if obj.hostname contains at least one colon.

@ghost ghost assigned isaacs Jun 3, 2011
@SaltwaterC
Copy link

If I ask for it, does it count?

$ node
> require('url').parse('http://[::1]/');
{ protocol: 'http:', slashes: true, host: '', hostname: '', href: 'http:///[::1]/', pathname: '[::1]/' }

Got little less than I was asking from url.parse().

@koichik
Copy link

koichik commented Jan 31, 2012

@shimaore - Thnaks, fixed in a94ffda.

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

No branches or pull requests

5 participants