defunctzombie / node-url

node.js core url module as a module
MIT License
375 stars 96 forks source link

`url.format` does not have same behavior for pathnames with and without slashes #43

Closed beck closed 6 years ago

beck commented 6 years ago

Problem

The docs say:

pathname is treated the same with or without the leading / (slash)

Example

Testing the lib in a console:

> const url = require('url');
undefined
> url.format({hostname: 'dougbeck.me', pathname: '/womp'})
'dougbeck.me/womp'
> url.format({hostname: 'dougbeck.me', pathname: 'womp'})
'dougbeck.mewomp'
beck commented 6 years ago

Is also a bug in node. Am closing because the better approach is to use WHATWG URL. rel: https://github.com/nodejs/help/issues/1176