@mcma/core 0.14.2 → 0.14.3

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,15 @@
1
1
  declare function isValidUrl(url: string): boolean;
2
+ export interface ParsedUrl {
3
+ href: string;
4
+ protocol: string;
5
+ host: string;
6
+ hostname: string;
7
+ port: string;
8
+ pathname: string;
9
+ search: string;
10
+ hash: string;
11
+ }
12
+ declare function parseUrl(href: string): ParsedUrl | null;
2
13
  declare function getTypeName(type: string | object | Function): string;
3
14
  declare function toBase64(text: string): string;
4
15
  declare function fromBase64(base64Text: string): string;
@@ -7,6 +18,7 @@ declare function isValidDateString(value: any): boolean;
7
18
  declare function reviver(this: any, key: string, value: any): any;
8
19
  export declare const Utils: {
9
20
  isValidUrl: typeof isValidUrl;
21
+ parseUrl: typeof parseUrl;
10
22
  getTypeName: typeof getTypeName;
11
23
  toBase64: typeof toBase64;
12
24
  fromBase64: typeof fromBase64;
package/dist/lib/utils.js CHANGED
@@ -11,6 +11,20 @@ function isValidUrl(url) {
11
11
  return false;
12
12
  }
13
13
  }
14
+ function parseUrl(href) {
15
+ var _a, _b, _c, _d, _e, _f, _g;
16
+ const match = href.match(/^(https?:)\/\/(([^:\/?#]*)(?::([0-9]+))?)([\/]?[^?#]*)(\?[^#]*|)(#.*|)$/);
17
+ return match && {
18
+ href: href !== null && href !== void 0 ? href : "",
19
+ protocol: (_a = match[1]) !== null && _a !== void 0 ? _a : "",
20
+ host: (_b = match[2]) !== null && _b !== void 0 ? _b : "",
21
+ hostname: (_c = match[3]) !== null && _c !== void 0 ? _c : "",
22
+ port: (_d = match[4]) !== null && _d !== void 0 ? _d : "",
23
+ pathname: (_e = match[5]) !== null && _e !== void 0 ? _e : "",
24
+ search: (_f = match[6]) !== null && _f !== void 0 ? _f : "",
25
+ hash: (_g = match[7]) !== null && _g !== void 0 ? _g : ""
26
+ };
27
+ }
14
28
  function getTypeName(type) {
15
29
  if (typeof type === "function") {
16
30
  type = type.name;
@@ -62,6 +76,7 @@ function reviver(key, value) {
62
76
  }
63
77
  exports.Utils = {
64
78
  isValidUrl,
79
+ parseUrl,
65
80
  getTypeName,
66
81
  toBase64,
67
82
  fromBase64,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcma/core",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "Node module with type definitions and helper utils for the EBU MCMA framework",
5
5
  "engines": {
6
6
  "node": "^14.17.0"