Skip to content

Instantly share code, notes, and snippets.

@manchicken
Created October 15, 2021 14:21
Show Gist options
  • Save manchicken/a9a2af089f45196802259e7402f1e7c5 to your computer and use it in GitHub Desktop.
Save manchicken/a9a2af089f45196802259e7402f1e7c5 to your computer and use it in GitHub Desktop.
url-string-antipattern-before
const { URL } = 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 = `${BASE_URL}/?url=${bookmark_url}`
console.log(constructed_url)
console.log(new URL(constructed_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment