zavadil-ts-common 1.2.76 → 1.2.77

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.
@@ -3,4 +3,5 @@ export declare class UrlUtil {
3
3
  static extractParamFromUrl(url: string, name: string): string | null;
4
4
  static paramExistsInUrl(url: string, name: string): boolean;
5
5
  static extractHostFromUrl(url: string): string | null;
6
+ static extractDomainFromUrl(url: string): string | null;
6
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zavadil-ts-common",
3
- "version": "1.2.76",
3
+ "version": "1.2.77",
4
4
  "description": "Common types and components for Typescript UI apps.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -16,9 +16,15 @@ export class UrlUtil {
16
16
  static paramExistsInUrl(url: string, name: string): boolean {
17
17
  return StringUtil.notBlank(UrlUtil.extractParamFromUrl(url, name));
18
18
  }
19
+
19
20
  static extractHostFromUrl(url: string): string | null {
20
21
  if (StringUtil.isBlank(url)) return null;
21
22
  return new URL(url).host;
22
23
  }
23
24
 
25
+ static extractDomainFromUrl(url: string): string | null {
26
+ const host = UrlUtil.extractHostFromUrl(url);
27
+ if (StringUtil.isBlank(host)) return null;
28
+ return host.split('.').slice(-2).join('.');
29
+ }
24
30
  }