rdapper 0.10.1 → 0.10.2

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/dist/index.js +12 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -547,14 +547,25 @@ function parseVcard(vcardArray) {
547
547
  //#endregion
548
548
  //#region src/whois/client.ts
549
549
  /**
550
+ * Some WHOIS servers default to non-English responses. This mapping allows automatic
551
+ * query transformation to request English-only output for easier parsing.
552
+ *
553
+ * To add new servers: Add an entry with the hostname and transformation function:
554
+ * "whois.example.org": (query) => `${query}/english`,
555
+ */
556
+ const WHOIS_QUERY_TRANSFORMERS = { "whois.jprs.jp": (query) => `${query}/e` };
557
+ /**
550
558
  * Perform a WHOIS query against an RFC 3912 server over TCP 43.
551
559
  * Returns the raw text and the server used.
552
560
  */
553
561
  async function whoisQuery(server, query, options) {
554
562
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
563
+ const port = 43;
564
+ const host = server.replace(/^whois:\/\//i, "");
565
+ const transformer = WHOIS_QUERY_TRANSFORMERS[host];
555
566
  return {
556
567
  serverQueried: server,
557
- text: await withTimeout(queryTcp(server.replace(/^whois:\/\//i, ""), 43, query, options), timeoutMs, "WHOIS timeout")
568
+ text: await withTimeout(queryTcp(host, port, transformer ? transformer(query) : query, options), timeoutMs, "WHOIS timeout")
558
569
  };
559
570
  }
560
571
  async function queryTcp(host, port, query, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdapper",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "license": "MIT",
5
5
  "description": "🎩 RDAP/WHOIS fetcher, parser, and normalizer for Node",
6
6
  "repository": {