@forge/egress 1.1.3-next.0 → 1.2.0-next.1

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.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 3bdedf0: Fix URL-constructor in Firefox browsers
8
+
3
9
  ## 1.1.3-next.0
4
10
 
5
11
  ### Patch Changes
@@ -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,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,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;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"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EgressFilteringService = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const minimatch_1 = tslib_1.__importDefault(require("minimatch"));
6
- const url_1 = require("url");
6
+ const url_parser_1 = require("./url-parser");
7
7
  class EgressFilteringService {
8
8
  constructor(allowList) {
9
9
  this.DEFAULT_PROTOCOL = 'https://';
@@ -16,8 +16,8 @@ class EgressFilteringService {
16
16
  }
17
17
  parseUrl(url) {
18
18
  const protocolRegex = /^(.*:\/\/)/;
19
- const urlParser = url_1.URL !== null && url_1.URL !== void 0 ? url_1.URL : window.URL;
20
- return new urlParser(protocolRegex.test(url) ? url : `${this.DEFAULT_PROTOCOL}${url}`);
19
+ const urlWithProtocol = protocolRegex.test(url) ? url : `${this.DEFAULT_PROTOCOL}${url}`;
20
+ return (0, url_parser_1.parseUrl)(urlWithProtocol);
21
21
  }
22
22
  isValidUrl(url) {
23
23
  if (this.allowsEverything) {
@@ -0,0 +1,3 @@
1
+ export declare type URLLike = Pick<URL, 'hostname' | 'protocol'>;
2
+ export declare function parseUrl(url: string): URLLike;
3
+ //# sourceMappingURL=url-parser.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseUrl = void 0;
4
+ function parseUrl(url) {
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];
8
+ return { protocol, hostname };
9
+ }
10
+ exports.parseUrl = parseUrl;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sortAndGroupEgressPermissionsByDomain = void 0;
4
4
  const minimatch_1 = require("minimatch");
5
- const url_1 = require("url");
5
+ const url_parser_1 = require("./url-parser");
6
6
  const sortAndGroupEgressPermissionsByDomain = (egressAddresses) => {
7
7
  if ((egressAddresses === null || egressAddresses === void 0 ? void 0 : egressAddresses.length) === 0) {
8
8
  return [];
@@ -12,7 +12,7 @@ const sortAndGroupEgressPermissionsByDomain = (egressAddresses) => {
12
12
  const wildcardDomains = [];
13
13
  egressAddresses.forEach((item) => {
14
14
  const itemWithProtocol = protocolRegex.test(item) ? item : `https://${item}`;
15
- const url = new url_1.URL(itemWithProtocol);
15
+ const url = (0, url_parser_1.parseUrl)(itemWithProtocol);
16
16
  if (url.hostname.startsWith('*')) {
17
17
  domains.add(url.hostname.substring(2));
18
18
  wildcardDomains.push((0, minimatch_1.makeRe)(url.hostname));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/egress",
3
- "version": "1.1.3-next.0",
3
+ "version": "1.2.0-next.1",
4
4
  "description": "Helpers and utils for egress implementation in Forge apps",
5
5
  "main": "out/index.js",
6
6
  "author": "Atlassian",