Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created November 30, 2018 17:24
Show Gist options
  • Save OliverJAsh/c57e89e7a3e1496001d7405cdcf83868 to your computer and use it in GitHub Desktop.
Save OliverJAsh/c57e89e7a3e1496001d7405cdcf83868 to your computer and use it in GitHub Desktop.
import * as urlHelpers from 'url';
import { UrlWithParsedQuery } from 'url';
import { pipe } from './helpers/pipe';
const parseUrlWithQueryString = (url: string): UrlWithParsedQuery =>
urlHelpers.parse(
url,
// Parse the query string
true,
);
const mapUrl = (fn: (parsedUrl: UrlWithParsedQuery) => UrlWithParsedQuery) =>
pipe(
parseUrlWithQueryString,
fn,
urlHelpers.format,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment