keep-a-changelog 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [2.5.3] - 2023-11-19
8
+ ### Fixed
9
+ - Improve URL normalization in CLI [#42]
10
+
7
11
  ## [2.5.2] - 2023-11-09
8
12
  ### Fixed
9
13
  - Url regex for gitlab links [#41]
@@ -88,7 +92,9 @@ New version merging Deno and Node code using Deno's `dnt` package.
88
92
  [#37]: https://github.com/oscarotero/keep-a-changelog/issues/37
89
93
  [#40]: https://github.com/oscarotero/keep-a-changelog/issues/40
90
94
  [#41]: https://github.com/oscarotero/keep-a-changelog/issues/41
95
+ [#42]: https://github.com/oscarotero/keep-a-changelog/issues/42
91
96
 
97
+ [2.5.3]: https://github.com/oscarotero/keep-a-changelog/compare/v2.5.2...v2.5.3
92
98
  [2.5.2]: https://github.com/oscarotero/keep-a-changelog/compare/v2.5.1...v2.5.2
93
99
  [2.5.1]: https://github.com/oscarotero/keep-a-changelog/compare/v2.5.0...v2.5.1
94
100
  [2.5.0]: https://github.com/oscarotero/keep-a-changelog/compare/v2.4.1...v2.5.0
package/esm/bin.js CHANGED
@@ -100,6 +100,17 @@ function red(message) {
100
100
  function green(message) {
101
101
  return "\u001b[" + 32 + "m" + message + "\u001b[" + 39 + "m";
102
102
  }
103
+ function normalizeUrl(url, https) {
104
+ // remove .git suffix
105
+ url = url.replace(/\.git$/, "");
106
+ // normalize git@host urls
107
+ if (url.startsWith("git@")) {
108
+ url = url.replace(/^git@([^:]+):(.*)$/, (https ? "https" : "http") + "://$1/$2");
109
+ }
110
+ // remove trailing slashes
111
+ url = url.replace(/\/+$/, "");
112
+ return new URL(url);
113
+ }
103
114
  function getRemoteUrl(https = true) {
104
115
  try {
105
116
  const file = join(dntShim.Deno.cwd(), ".git", "config");
@@ -109,12 +120,7 @@ function getRemoteUrl(https = true) {
109
120
  if (!url) {
110
121
  return;
111
122
  }
112
- const remoteUrl = new URL(url.replace(/^git@([^:]+):(.*)\.git$/, "https://$1/$2"));
113
- if (https) {
114
- remoteUrl.protocol = "https:";
115
- }
116
- // remove trailing slashes
117
- return remoteUrl.href.replace(/\/+$/, "");
123
+ return normalizeUrl(url, https).href;
118
124
  }
119
125
  catch (err) {
120
126
  console.error(red(err.message));
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "changelog": "./esm/bin.js"
6
6
  },
7
7
  "name": "keep-a-changelog",
8
- "version": "2.5.2",
8
+ "version": "2.5.3",
9
9
  "description": "Node package to parse and generate changelogs following the [keepachangelog](https://keepachangelog.com/) format.",
10
10
  "homepage": "https://github.com/oscarotero/keep-a-changelog#readme",
11
11
  "license": "MIT",
package/script/bin.js CHANGED
@@ -128,6 +128,17 @@ function red(message) {
128
128
  function green(message) {
129
129
  return "\u001b[" + 32 + "m" + message + "\u001b[" + 39 + "m";
130
130
  }
131
+ function normalizeUrl(url, https) {
132
+ // remove .git suffix
133
+ url = url.replace(/\.git$/, "");
134
+ // normalize git@host urls
135
+ if (url.startsWith("git@")) {
136
+ url = url.replace(/^git@([^:]+):(.*)$/, (https ? "https" : "http") + "://$1/$2");
137
+ }
138
+ // remove trailing slashes
139
+ url = url.replace(/\/+$/, "");
140
+ return new URL(url);
141
+ }
131
142
  function getRemoteUrl(https = true) {
132
143
  try {
133
144
  const file = (0, mod_js_1.join)(dntShim.Deno.cwd(), ".git", "config");
@@ -137,12 +148,7 @@ function getRemoteUrl(https = true) {
137
148
  if (!url) {
138
149
  return;
139
150
  }
140
- const remoteUrl = new URL(url.replace(/^git@([^:]+):(.*)\.git$/, "https://$1/$2"));
141
- if (https) {
142
- remoteUrl.protocol = "https:";
143
- }
144
- // remove trailing slashes
145
- return remoteUrl.href.replace(/\/+$/, "");
151
+ return normalizeUrl(url, https).href;
146
152
  }
147
153
  catch (err) {
148
154
  console.error(red(err.message));