@forge/egress 1.2.0 → 1.2.1-next.0

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,11 @@
1
1
  # @forge/egress
2
2
 
3
+ ## 1.2.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - f18ccd86: Fixed bug greedily extracting the protocol from provided egress domains
8
+
3
9
  ## 1.2.0
4
10
 
5
11
  ### Minor Changes
@@ -2,7 +2,6 @@ export declare class EgressFilteringService {
2
2
  private readonly URLs;
3
3
  private readonly wildcardDomains;
4
4
  private readonly allowsEverything;
5
- private readonly DEFAULT_PROTOCOL;
6
5
  constructor(allowList: string[]);
7
6
  private parseUrl;
8
7
  isValidUrl(url: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"egress-filtering-service.d.ts","sourceRoot":"","sources":["../../src/egress/egress-filtering-service.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAY;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAc;gBAEnC,SAAS,EAAE,MAAM,EAAE;IAU/B,OAAO,CAAC,QAAQ;IAQT,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IASvC,OAAO,CAAC,aAAa;CAKtB"}
1
+ {"version":3,"file":"egress-filtering-service.d.ts","sourceRoot":"","sources":["../../src/egress/egress-filtering-service.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAY;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;gBAE/B,SAAS,EAAE,MAAM,EAAE;IAU/B,OAAO,CAAC,QAAQ;IAKT,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IASvC,OAAO,CAAC,aAAa;CAKtB"}
@@ -6,7 +6,6 @@ const minimatch_1 = tslib_1.__importDefault(require("minimatch"));
6
6
  const url_parser_1 = require("./url-parser");
7
7
  class EgressFilteringService {
8
8
  constructor(allowList) {
9
- this.DEFAULT_PROTOCOL = 'https://';
10
9
  this.URLs = allowList.filter((domainOrURL) => !domainOrURL.startsWith('*')).map((url) => this.parseUrl(url));
11
10
  this.wildcardDomains = allowList
12
11
  .filter((domainOrURL) => domainOrURL !== '*')
@@ -15,9 +14,7 @@ class EgressFilteringService {
15
14
  this.allowsEverything = allowList.includes('*');
16
15
  }
17
16
  parseUrl(url) {
18
- const protocolRegex = /^(.*:\/\/)/;
19
- const urlWithProtocol = protocolRegex.test(url) ? url : `${this.DEFAULT_PROTOCOL}${url}`;
20
- return (0, url_parser_1.parseUrl)(urlWithProtocol);
17
+ return (0, url_parser_1.parseUrl)(url);
21
18
  }
22
19
  isValidUrl(url) {
23
20
  if (this.allowsEverything) {
@@ -1 +1 @@
1
- {"version":3,"file":"url-parser.d.ts","sourceRoot":"","sources":["../../src/egress/url-parser.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;AAKzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAK7C"}
1
+ {"version":3,"file":"url-parser.d.ts","sourceRoot":"","sources":["../../src/egress/url-parser.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;AAKzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQ7C"}
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseUrl = void 0;
4
4
  function parseUrl(url) {
5
5
  var _a, _b;
6
- const protocol = (_b = (_a = url.match(/^(.*:\/\/)/)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'https://';
7
- const hostname = url.replace(protocol, '').split(/[\/?]/)[0];
6
+ const protocol = (_b = (_a = url.match(/^(.*?:)/)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'https:';
7
+ const hostname = url
8
+ .replace(protocol, '')
9
+ .replace(/^\/*/, '')
10
+ .split(/[\?\/]/)[0];
8
11
  return { protocol, hostname };
9
12
  }
10
13
  exports.parseUrl = parseUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/egress",
3
- "version": "1.2.0",
3
+ "version": "1.2.1-next.0",
4
4
  "description": "Helpers and utils for egress implementation in Forge apps",
5
5
  "main": "out/index.js",
6
6
  "author": "Atlassian",