Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created November 30, 2018 17:24
Show Gist options
  • Save OliverJAsh/ca8fafdbd2f53d59fcb7a21324c12900 to your computer and use it in GitHub Desktop.
Save OliverJAsh/ca8fafdbd2f53d59fcb7a21324c12900 to your computer and use it in GitHub Desktop.
const addSearchStringToUrl = (url: string, searchString: string) =>
`${url}?${searchString}`;
addSearchStringToUrl('http://foo.com/', 'a=b');
// => http://foo.com/?a=b
const appendPathnameToUrl = (url: string, pathnameToAppend: string) =>
`${url}${pathnameToAppend}`;
appendPathnameToUrl('http://foo.com/users', '/bob');
// => http://foo.com/users/bob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment