Created
October 15, 2021 14:38
-
-
Save manchicken/e8acd65e9f9067b28d1c25f89d54827d to your computer and use it in GitHub Desktop.
url-string-antipattern-after
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { URL, URLSearchParams } = require('url') | |
const BASE_URL = 'https://api.foobar.com/api/bookmark' | |
const bookmark_url = 'https://www.reddit.com/r/chickens/search/?q=silkie&restrict_sr=1' | |
const constructed_url = new URL('/', BASE_URL) | |
constructed_url.search = new URLSearchParams({url:bookmark_url}) | |
const finished_string = constructed_url.toString() | |
console.log(finished_string) | |
console.log(new URL(finished_string)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment