tldts 5.7.86 → 5.7.87

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.
Files changed (2) hide show
  1. package/index.ts +62 -0
  2. package/package.json +6 -5
package/index.ts ADDED
@@ -0,0 +1,62 @@
1
+ import {
2
+ FLAG,
3
+ getEmptyResult,
4
+ IOptions,
5
+ IResult,
6
+ parseImpl,
7
+ resetResult,
8
+ } from 'tldts-core';
9
+
10
+ import suffixLookup from './src/suffix-trie';
11
+
12
+ // For all methods but 'parse', it does not make sense to allocate an object
13
+ // every single time to only return the value of a specific attribute. To avoid
14
+ // this un-necessary allocation, we use a global object which is re-used.
15
+ const RESULT: IResult = getEmptyResult();
16
+
17
+ export function parse(url: string, options: Partial<IOptions> = {}): IResult {
18
+ return parseImpl(url, FLAG.ALL, suffixLookup, options, getEmptyResult());
19
+ }
20
+
21
+ export function getHostname(
22
+ url: string,
23
+ options: Partial<IOptions> = {},
24
+ ): string | null {
25
+ /*@__INLINE__*/ resetResult(RESULT);
26
+ return parseImpl(url, FLAG.HOSTNAME, suffixLookup, options, RESULT).hostname;
27
+ }
28
+
29
+ export function getPublicSuffix(
30
+ url: string,
31
+ options: Partial<IOptions> = {},
32
+ ): string | null {
33
+ /*@__INLINE__*/ resetResult(RESULT);
34
+ return parseImpl(url, FLAG.PUBLIC_SUFFIX, suffixLookup, options, RESULT)
35
+ .publicSuffix;
36
+ }
37
+
38
+ export function getDomain(
39
+ url: string,
40
+ options: Partial<IOptions> = {},
41
+ ): string | null {
42
+ /*@__INLINE__*/ resetResult(RESULT);
43
+ return parseImpl(url, FLAG.DOMAIN, suffixLookup, options, RESULT).domain;
44
+ }
45
+
46
+ export function getSubdomain(
47
+ url: string,
48
+ options: Partial<IOptions> = {},
49
+ ): string | null {
50
+ /*@__INLINE__*/ resetResult(RESULT);
51
+ return parseImpl(url, FLAG.SUB_DOMAIN, suffixLookup, options, RESULT)
52
+ .subdomain;
53
+ }
54
+
55
+ export function getDomainWithoutSuffix(
56
+ url: string,
57
+ options: Partial<IOptions> = {},
58
+ ): string | null {
59
+ /*@__INLINE__*/ resetResult(RESULT);
60
+ return parseImpl(url, FLAG.ALL, suffixLookup, options, RESULT)
61
+ .domainWithoutSuffix;
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tldts",
3
- "version": "5.7.86",
3
+ "version": "5.7.87",
4
4
  "description": "Library to work against complex domain names, subdomains and URIs.",
5
5
  "author": {
6
6
  "name": "Rémi Berson"
@@ -40,7 +40,8 @@
40
40
  "types": "dist/types/index.d.ts",
41
41
  "files": [
42
42
  "dist",
43
- "src"
43
+ "src",
44
+ "index.ts"
44
45
  ],
45
46
  "bin": {
46
47
  "tldts": "bin/cli.js"
@@ -65,13 +66,13 @@
65
66
  "rollup": "^2.50.4",
66
67
  "rollup-plugin-sourcemaps": "^0.6.1",
67
68
  "rollup-plugin-terser": "^7.0.2",
68
- "tldts-tests": "^5.7.86",
69
+ "tldts-tests": "^5.7.87",
69
70
  "tslint": "^6.0.0",
70
71
  "tslint-config-prettier": "^1.18.0",
71
72
  "typescript": "^4.3.2"
72
73
  },
73
74
  "dependencies": {
74
- "tldts-core": "^5.7.86"
75
+ "tldts-core": "^5.7.87"
75
76
  },
76
77
  "keywords": [
77
78
  "tld",
@@ -88,5 +89,5 @@
88
89
  "url parsing",
89
90
  "typescript"
90
91
  ],
91
- "gitHead": "614fda0fa0ecdd23dd18db00788b61a41e1f7c08"
92
+ "gitHead": "275f15b30cd24aa29758b8b73de59d6b96e1290c"
92
93
  }