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.
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/util/UrlUtil.d.ts +1 -0
- package/package.json +1 -1
- package/src/util/UrlUtil.ts +6 -0
package/dist/util/UrlUtil.d.ts
CHANGED
|
@@ -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
package/src/util/UrlUtil.ts
CHANGED
|
@@ -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
|
}
|