keep-a-changelog
Advanced tools
Comparing version 2.5.2 to 2.5.3
@@ -7,2 +7,6 @@ # Changelog | ||
## [2.5.3] - 2023-11-19 | ||
### Fixed | ||
- Improve URL normalization in CLI [#42] | ||
## [2.5.2] - 2023-11-09 | ||
@@ -92,3 +96,5 @@ ### Fixed | ||
[#41]: https://github.com/oscarotero/keep-a-changelog/issues/41 | ||
[#42]: https://github.com/oscarotero/keep-a-changelog/issues/42 | ||
[2.5.3]: https://github.com/oscarotero/keep-a-changelog/compare/v2.5.2...v2.5.3 | ||
[2.5.2]: https://github.com/oscarotero/keep-a-changelog/compare/v2.5.1...v2.5.2 | ||
@@ -95,0 +101,0 @@ [2.5.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.5.0...v2.5.1 |
@@ -103,2 +103,13 @@ #!/usr/bin/env node | ||
} | ||
function normalizeUrl(url, https) { | ||
// remove .git suffix | ||
url = url.replace(/\.git$/, ""); | ||
// normalize git@host urls | ||
if (url.startsWith("git@")) { | ||
url = url.replace(/^git@([^:]+):(.*)$/, (https ? "https" : "http") + "://$1/$2"); | ||
} | ||
// remove trailing slashes | ||
url = url.replace(/\/+$/, ""); | ||
return new URL(url); | ||
} | ||
function getRemoteUrl(https = true) { | ||
@@ -113,8 +124,3 @@ try { | ||
} | ||
const remoteUrl = new URL(url.replace(/^git@([^:]+):(.*)\.git$/, "https://$1/$2")); | ||
if (https) { | ||
remoteUrl.protocol = "https:"; | ||
} | ||
// remove trailing slashes | ||
return remoteUrl.href.replace(/\/+$/, ""); | ||
return normalizeUrl(url, https).href; | ||
} | ||
@@ -121,0 +127,0 @@ catch (err) { |
@@ -8,3 +8,3 @@ { | ||
"name": "keep-a-changelog", | ||
"version": "2.5.2", | ||
"version": "2.5.3", | ||
"description": "Node package to parse and generate changelogs following the [keepachangelog](https://keepachangelog.com/) format.", | ||
@@ -11,0 +11,0 @@ "homepage": "https://github.com/oscarotero/keep-a-changelog#readme", |
@@ -131,2 +131,13 @@ #!/usr/bin/env node | ||
} | ||
function normalizeUrl(url, https) { | ||
// remove .git suffix | ||
url = url.replace(/\.git$/, ""); | ||
// normalize git@host urls | ||
if (url.startsWith("git@")) { | ||
url = url.replace(/^git@([^:]+):(.*)$/, (https ? "https" : "http") + "://$1/$2"); | ||
} | ||
// remove trailing slashes | ||
url = url.replace(/\/+$/, ""); | ||
return new URL(url); | ||
} | ||
function getRemoteUrl(https = true) { | ||
@@ -141,8 +152,3 @@ try { | ||
} | ||
const remoteUrl = new URL(url.replace(/^git@([^:]+):(.*)\.git$/, "https://$1/$2")); | ||
if (https) { | ||
remoteUrl.protocol = "https:"; | ||
} | ||
// remove trailing slashes | ||
return remoteUrl.href.replace(/\/+$/, ""); | ||
return normalizeUrl(url, https).href; | ||
} | ||
@@ -149,0 +155,0 @@ catch (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
576004
14220