Skip to content

Instantly share code, notes, and snippets.

@elado
Created November 7, 2016 22:07
Show Gist options
  • Save elado/d86f04b8d5cf7e3c6f92c207162d4aea to your computer and use it in GitHub Desktop.
Save elado/d86f04b8d5cf7e3c6f92c207162d4aea to your computer and use it in GitHub Desktop.
function urlEncodedTaggedString(strings, ...substitutions) {
let result = strings[0]
for (let i = 0; i < substitutions.length; ++i) {
result += encodeURIComponent(substitutions[i])
result += strings[i + 1]
}
return result
}
let name = 'I have ? and #!'
let url = urlEncodedTaggedString`/person/${name}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment