Skip to content

Instantly share code, notes, and snippets.

@pinkhominid
Last active January 16, 2020 17:25
Show Gist options
  • Save pinkhominid/903d3f9d33ca16d25e06eeb04f1700a9 to your computer and use it in GitHub Desktop.
Save pinkhominid/903d3f9d33ca16d25e06eeb04f1700a9 to your computer and use it in GitHub Desktop.
areUrlsEqual()
// Handles root path slash and casing diffs correctly. For example:
// areUrlsEqual('http://example.com', 'http://Example.com/') => true
export default function areUrlsEqual(url1, url2) {
const u1 = new URL(url1);
const u2 = new URL(url2);
return u1.toString() === u2.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment