9c6ee729d6
GitOrigin-RevId: 6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222
17 lines
634 B
JavaScript
17 lines
634 B
JavaScript
const path = require('path')
|
|
|
|
// This has to match the logic in pkgs/development/tools/yarn2nix-moretea/yarn2nix/lib/urlToName.js
|
|
// so that fixup_yarn_lock produces the same paths
|
|
const urlToName = url => {
|
|
const isCodeloadGitTarballUrl = url.startsWith('https://codeload.github.com/') && url.includes('/tar.gz/')
|
|
|
|
if (url.startsWith('git+') || isCodeloadGitTarballUrl) {
|
|
return path.basename(url)
|
|
} else {
|
|
return url
|
|
.replace(/https:\/\/(.)*(.com)\//g, '') // prevents having long directory names
|
|
.replace(/[@/%:-]/g, '_') // replace @ and : and - and % characters with underscore
|
|
}
|
|
}
|
|
|
|
module.exports = { urlToName };
|