semantic-release 26.0.0-beta.4 → 26.0.0-beta.5

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.
@@ -1,4 +1,4 @@
1
- import { format, parse } from "node:url";
1
+ import { format } from "node:url";
2
2
  import { isNil } from "lodash-es";
3
3
  import hostedGitInfo from "hosted-git-info";
4
4
  import debugAuthUrl from "debug";
@@ -6,6 +6,17 @@ import { verifyAuth } from "./git.js";
6
6
 
7
7
  const debug = debugAuthUrl("semantic-release:get-git-auth-url");
8
8
 
9
+ /**
10
+ * Get the protocol of a repository URL, if it has one (`null` for scp-like and shorthand URLs)
11
+ *
12
+ * @param {String} repositoryUrl User-given repository URL
13
+ *
14
+ * @return {String|null} The protocol, including the trailing `:`
15
+ */
16
+ function getProtocol(repositoryUrl) {
17
+ return URL.canParse(repositoryUrl) ? new URL(repositoryUrl).protocol : null;
18
+ }
19
+
9
20
  /**
10
21
  * Machinery to format a repository URL with the given credentials
11
22
  *
@@ -22,12 +33,14 @@ function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
22
33
 
23
34
  const [match, auth, host, basePort, path] =
24
35
  /^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
25
- const { port, hostname, ...parsed } = parse(
36
+ const { port, hostname, pathname, search, hash } = new URL(
26
37
  match ? `ssh://${auth ? `${auth}@` : ""}${host}${basePort ? `:${basePort}` : ""}/${path}` : repositoryUrl
27
38
  );
28
39
 
29
40
  return format({
30
- ...parsed,
41
+ pathname,
42
+ search,
43
+ hash,
31
44
  auth: gitCredentials,
32
45
  host: `${hostname}${protocol === "ssh:" ? "" : port ? `:${port}` : ""}`,
33
46
  protocol: protocol && /http[^s]/.test(protocol) ? "http" : "https",
@@ -81,14 +94,14 @@ export default async (context) => {
81
94
 
82
95
  let { repositoryUrl } = context.options;
83
96
  const info = hostedGitInfo.fromUrl(repositoryUrl, { noGitPlus: true });
84
- const { protocol, ...parsed } = parse(repositoryUrl);
97
+ const protocol = getProtocol(repositoryUrl);
85
98
 
86
99
  if (info && info.getDefaultRepresentation() === "shortcut") {
87
100
  // Expand shorthand URLs (such as `owner/repo` or `gitlab:owner/repo`)
88
101
  repositoryUrl = info.https();
89
102
  } else if (protocol && protocol.includes("http")) {
90
103
  // Replace `git+https` and `git+http` with `https` or `http`
91
- repositoryUrl = format({ ...parsed, protocol: protocol.includes("https") ? "https" : "http", href: null });
104
+ repositoryUrl = repositoryUrl.replace(/^[^:]+:/, protocol.includes("https") ? "https:" : "http:");
92
105
  }
93
106
 
94
107
  // Test if push is allowed without transforming the URL (e.g. is ssh keys are set up)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "semantic-release",
3
3
  "description": "Automated semver compliant package publishing",
4
- "version": "26.0.0-beta.4",
4
+ "version": "26.0.0-beta.5",
5
5
  "type": "module",
6
6
  "author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
7
7
  "ava": {