@backstage/integration 1.6.1 → 1.6.2

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
@@ -1,5 +1,14 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - cf196443d8da: Additional fix for Gitiles auth links
8
+ - Updated dependencies
9
+ - @backstage/config@1.0.8
10
+ - @backstage/errors@1.2.1
11
+
3
12
  ## 1.6.1
4
13
 
5
14
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1037,13 +1037,23 @@ function getAuthenticationPrefix(config) {
1037
1037
  return config.password ? "/a/" : "/";
1038
1038
  }
1039
1039
  function getGitilesAuthenticationUrl(config) {
1040
- const parsedUrl = new URL(config.gitilesBaseUrl);
1041
- parsedUrl.pathname = parsedUrl.pathname.replace(/\/?$/, "");
1042
- parsedUrl.pathname = parsedUrl.pathname.replace(
1043
- /\/([^\/]*)$/,
1044
- `${getAuthenticationPrefix(config)}$1`
1045
- );
1046
- return parsedUrl.toString();
1040
+ if (!config.baseUrl || !config.gitilesBaseUrl) {
1041
+ throw new Error(
1042
+ "Unexpected Gerrit config values. baseUrl or gitilesBaseUrl not set."
1043
+ );
1044
+ }
1045
+ if (config.gitilesBaseUrl.startsWith(config.baseUrl)) {
1046
+ return config.gitilesBaseUrl.replace(
1047
+ config.baseUrl.concat("/"),
1048
+ config.baseUrl.concat(getAuthenticationPrefix(config))
1049
+ );
1050
+ }
1051
+ if (config.password) {
1052
+ throw new Error(
1053
+ "Since the baseUrl (Gerrit) is not part of the gitilesBaseUrl, an authentication URL could not be constructed."
1054
+ );
1055
+ }
1056
+ return config.gitilesBaseUrl;
1047
1057
  }
1048
1058
  function getGerritBranchApiUrl(config, url) {
1049
1059
  const { branch, project } = parseGerritGitilesUrl(config, url);