Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL() constructor #117

Closed
onlywei opened this issue Oct 5, 2015 · 14 comments
Closed

URL() constructor #117

onlywei opened this issue Oct 5, 2015 · 14 comments

Comments

@onlywei
Copy link

onlywei commented Oct 5, 2015

Hello,

Are there any plans to add the URL constructor to this library?
https://developer.mozilla.org/en-US/docs/Web/API/URL/URL

Thanks.

@zloirock
Copy link
Owner

zloirock commented Oct 6, 2015

Thanks for proposal, I will think about it.

@zloirock
Copy link
Owner

zloirock commented Feb 6, 2016

I think, it's possible to add minimalistic implementation like that: https://gist.github.com/Yaffle/1088850

@zloirock
Copy link
Owner

zloirock commented Apr 4, 2017

In #288 proposed an option.

@zloirock
Copy link
Owner

zloirock commented Dec 1, 2017

Now it's an ECMAScript proposal, https://github.com/jasnell/proposal-url.

@KevinSnyderCodes
Copy link

jsdom implemented the URL class to the WHATWG standard: https://github.com/jsdom/whatwg-url

Would you be OK with using their code and formatting it to match the structure of your project? They also use the MIT license.

@kof
Copy link

kof commented Mar 1, 2018

what about using something like this as a polyfill?

import pick from 'lodash/object/pick'
import mapValues from 'lodash/object/mapValues'

const parser = document.createElement('a')

const components = [
  'hash', 'host', 'hostname', 'href', 'pathname', 'port', 'protocol', 'search'
]

export default function parse(url) {
  parser.href = encodeURI(url)
  return mapValues(pick(parser, components), decodeURIComponent)
}

@zloirock
Copy link
Owner

zloirock commented Mar 6, 2018

@kof at least, document.createElement('a') is not available in non-browser engines.

@zloirock
Copy link
Owner

zloirock commented Mar 6, 2018

@KevinSnyderCodes feel free to add it after merging v3 branch with master.

@yvele
Copy link

yvele commented Sep 26, 2018

Is this issue also covering URLSearchParams polyfill?

Note that 2 polyfills already exists

@zloirock
Copy link
Owner

@yvele yes, includes.

@zloirock
Copy link
Owner

Most likely, it will be added soon. I'm working on it.

@loganfsmyth
Copy link
Contributor

@zloirock Would this be on by default, or opt in? I wouldn't want users of babel-polyfill to load this I don't think, at least not without opting in.

@zloirock
Copy link
Owner

zloirock commented Oct 19, 2018

@loganfsmyth it will be available in namespaces core-js/web and core-js/stage/0. Sure, in the main entry point too, but babel-polyfill don't use it.

@zloirock
Copy link
Owner

Available in core-js@3.0.0-beta.5.

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

No branches or pull requests

6 participants