-
Notifications
You must be signed in to change notification settings - Fork 491
Open
Description
Chapter 20 url.parse() is deprecated and needs to be updated to use WhatWg URL API.
https://nodejs.org/api/url.html#the-whatwg-url-api
https://url.spec.whatwg.org/
DEPRECATED url.parse() syntax:
const url = require('url');
const myUrl = url.parse("https://www.example.com/listing?id=1000&premium=true");
console.log(myUrl); // the url object
console.log(`Host: ${myUrl.host}`); // www.example.com
WhatWg URL API syntax:
// taken from nodejs.org:
// The new URL constructor is accessible as a property of the global object.
// It can also be imported from the built-in url module.
const myUrl = new URL("https://www.example.com/listing?id=1000&premium=true");
console.log(myUrl); // the url object
console.log(`Host: ${myUrl.host}`); // www.example.com
Metadata
Metadata
Assignees
Labels
No labels