@cleandns/whois-rdap 1.0.30 → 1.0.31

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,5 +1,5 @@
1
1
  import { ParseResultType, parseDomain } from "parse-domain";
2
- const tldCache = new Map([]);
2
+ let tldCache = new Map([]);
3
3
  const tldCachePresets = [
4
4
  ["it.com", null],
5
5
  ["br.com", "https://rdap.centralnic.com/br.com"],
@@ -27,16 +27,18 @@ const tldCachePresets = [
27
27
  ];
28
28
  export async function tldToRdap(domain) {
29
29
  if (tldCache.size === 0) {
30
+ const tmpCache = new Map([]);
30
31
  for (const [tld, url] of tldCachePresets) {
31
- tldCache.set(tld, url);
32
+ tmpCache.set(tld, url);
32
33
  }
33
34
  // console.warn(`fetching tld-to-rdap`);
34
35
  const response = await fetch(`https://data.iana.org/rdap/dns.json`).then((r) => r.json());
35
36
  for (const [tlds, urls] of response.services) {
36
37
  for (const tld of tlds) {
37
- tldCache.set(tld, urls[0].replace(/\/$/, ""));
38
+ tmpCache.set(tld, urls[0].replace(/\/$/, ""));
38
39
  }
39
40
  }
41
+ tldCache = tmpCache;
40
42
  }
41
43
  const parsed = parseDomain(domain);
42
44
  if (parsed.type === ParseResultType.Listed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleandns/whois-rdap",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +1,7 @@
1
1
  import { ParseResultType, parseDomain } from "parse-domain";
2
2
 
3
3
  type TldToRdap = [string[], string[]];
4
- const tldCache = new Map<string, string | null>([]);
4
+ let tldCache = new Map<string, string | null>([]);
5
5
  const tldCachePresets: [string, string | null][] = [
6
6
  ["it.com", null],
7
7
  ["br.com", "https://rdap.centralnic.com/br.com"],
@@ -32,8 +32,9 @@ export async function tldToRdap(
32
32
  domain: string
33
33
  ): Promise<[string, string | null]> {
34
34
  if (tldCache.size === 0) {
35
+ const tmpCache = new Map<string, string | null>([]);
35
36
  for (const [tld, url] of tldCachePresets) {
36
- tldCache.set(tld, url);
37
+ tmpCache.set(tld, url);
37
38
  }
38
39
 
39
40
  // console.warn(`fetching tld-to-rdap`);
@@ -43,9 +44,10 @@ export async function tldToRdap(
43
44
 
44
45
  for (const [tlds, urls] of response.services) {
45
46
  for (const tld of tlds) {
46
- tldCache.set(tld, urls[0].replace(/\/$/, ""));
47
+ tmpCache.set(tld, urls[0].replace(/\/$/, ""));
47
48
  }
48
49
  }
50
+ tldCache = tmpCache;
49
51
  }
50
52
 
51
53
  const parsed = parseDomain(domain);