Skip to content

url.parse now encodes components #2113

Description

@sethfitz

This behavior changed between Node-0.10 and 0.12/iojs and does not appear to be documented anywhere.

io.js v2.3.3:

> url.parse("http://example.com/{z}/{x}/{y}.png#foo{}")
{ protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'example.com',
  port: null,
  hostname: 'example.com',
  hash: '#foo%7B%7D',
  search: null,
  query: null,
  pathname: '/%7Bz%7D/%7Bx%7D/%7By%7D.png',
  path: '/%7Bz%7D/%7Bx%7D/%7By%7D.png',
  href: 'http://example.com/%7Bz%7D/%7Bx%7D/%7By%7D.png#foo%7B%7D' }

node.js v0.10.39:

> url.parse("http://example.com/{z}/{x}/{y}.png#foo{}")
{ protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'example.com',
  port: null,
  hostname: 'example.com',
  hash: '#foo{}',
  search: null,
  query: null,
  pathname: '/{z}/{x}/{y}.png',
  path: '/{z}/{x}/{y}.png',
  href: 'http://example.com/{z}/{x}/{y}.png#foo{}' }

This also means that URIs no longer roundtrip:

iojs v2.3.3

> url.format(url.parse("http://example.com/{z}/{x}/{y}.png#foo{}"))
'http://example.com/%7Bz%7D/%7Bx%7D/%7By%7D.png#foo%7B%7D'

node.js v0.10.39:

> url.format(url.parse("http://example.com/{z}/{x}/{y}.png#foo{}"))
'http://example.com/{z}/{x}/{y}.png#foo{}'

Activity

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

Metadata

Metadata

Assignees

Labels

urlIssues and PRs related to the legacy built-in url module.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions