Converting hns domain to punycode (Fix for #458)
This commit is contained in:
parent
a44b655ba5
commit
a2265cdd79
|
@ -1,4 +1,5 @@
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
|
const punycode = require("punycode");
|
||||||
const NodeCache = require("node-cache");
|
const NodeCache = require("node-cache");
|
||||||
const { NodeClient } = require("hs-client");
|
const { NodeClient } = require("hs-client");
|
||||||
|
|
||||||
|
@ -51,11 +52,12 @@ const getSkylinkFromRecord = (record) => {
|
||||||
|
|
||||||
const resolveDomainHandler = async (req, res) => {
|
const resolveDomainHandler = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const records = await getDomainRecords(req.params.name);
|
const domain = punycode.toASCII(req.params.name);
|
||||||
if (!records) return res.status(404).send(`No records found for ${req.params.name}`);
|
const records = await getDomainRecords(domain);
|
||||||
|
if (!records) return res.status(404).send(`No records found for ${domain}`);
|
||||||
|
|
||||||
const record = findSkylinkRecord(records);
|
const record = findSkylinkRecord(records);
|
||||||
if (!record) throw new Error(`No skylink found in dns records of ${req.params.name}`);
|
if (!record) throw new Error(`No skylink found in dns records of ${domain}`);
|
||||||
|
|
||||||
const skylink = getSkylinkFromRecord(record);
|
const skylink = getSkylinkFromRecord(record);
|
||||||
return res.json({ skylink });
|
return res.json({ skylink });
|
||||||
|
|
Reference in New Issue