mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 12:45:25 +00:00

PR-URL: https://github.com/nodejs/node/pull/35474 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
19 lines
450 B
JavaScript
19 lines
450 B
JavaScript
const { URL } = require('url')
|
|
|
|
/**
|
|
* Maps a URL to an identifier.
|
|
*
|
|
* Name courtesy schiffertronix media LLC, a New Jersey corporation
|
|
*
|
|
* @param {String} uri The URL to be nerfed.
|
|
*
|
|
* @returns {String} A nerfed URL.
|
|
*/
|
|
module.exports = (url) => {
|
|
const parsed = new URL(url)
|
|
const from = `${parsed.protocol}//${parsed.host}${parsed.pathname}`
|
|
const rel = new URL('.', from)
|
|
const res = `//${rel.host}${rel.pathname}`
|
|
return res
|
|
}
|