@backstage/integration 1.7.0-next.0 → 1.7.0-next.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,22 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.7.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/config@1.1.0-next.1
9
+ - @backstage/errors@1.2.1
10
+
11
+ ## 1.7.0-next.1
12
+
13
+ ### Patch Changes
14
+
15
+ - 2d2fc9d20ebb: Additional fix for Gitiles auth links
16
+ - Updated dependencies
17
+ - @backstage/config@1.1.0-next.0
18
+ - @backstage/errors@1.2.1
19
+
3
20
  ## 1.7.0-next.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -1282,13 +1282,23 @@ function getAuthenticationPrefix(config) {
1282
1282
  return config.password ? "/a/" : "/";
1283
1283
  }
1284
1284
  function getGitilesAuthenticationUrl(config) {
1285
- const parsedUrl = new URL(config.gitilesBaseUrl);
1286
- parsedUrl.pathname = parsedUrl.pathname.replace(/\/?$/, "");
1287
- parsedUrl.pathname = parsedUrl.pathname.replace(
1288
- /\/([^\/]*)$/,
1289
- `${getAuthenticationPrefix(config)}$1`
1290
- );
1291
- return parsedUrl.toString();
1285
+ if (!config.baseUrl || !config.gitilesBaseUrl) {
1286
+ throw new Error(
1287
+ "Unexpected Gerrit config values. baseUrl or gitilesBaseUrl not set."
1288
+ );
1289
+ }
1290
+ if (config.gitilesBaseUrl.startsWith(config.baseUrl)) {
1291
+ return config.gitilesBaseUrl.replace(
1292
+ config.baseUrl.concat("/"),
1293
+ config.baseUrl.concat(getAuthenticationPrefix(config))
1294
+ );
1295
+ }
1296
+ if (config.password) {
1297
+ throw new Error(
1298
+ "Since the baseUrl (Gerrit) is not part of the gitilesBaseUrl, an authentication URL could not be constructed."
1299
+ );
1300
+ }
1301
+ return config.gitilesBaseUrl;
1292
1302
  }
1293
1303
  function getGerritBranchApiUrl(config, url) {
1294
1304
  const { branch, project } = parseGerritGitilesUrl(config, url);