Merge pull request #470 from Delivator/hns-api-punycode-fix
Hns api punycode fix (#458 fix)
This commit is contained in:
commit
9deb1b014c
|
@ -6,7 +6,8 @@
|
|||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"hs-client": "^0.0.9",
|
||||
"node-cache": "^5.1.2"
|
||||
"node-cache": "^5.1.2",
|
||||
"punycode": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.0.5"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const express = require("express");
|
||||
const punycode = require("punycode");
|
||||
const NodeCache = require("node-cache");
|
||||
const { NodeClient } = require("hs-client");
|
||||
|
||||
|
@ -51,11 +52,12 @@ const getSkylinkFromRecord = (record) => {
|
|||
|
||||
const resolveDomainHandler = async (req, res) => {
|
||||
try {
|
||||
const records = await getDomainRecords(req.params.name);
|
||||
if (!records) return res.status(404).send(`No records found for ${req.params.name}`);
|
||||
const domain = punycode.toASCII(req.params.name);
|
||||
const records = await getDomainRecords(domain);
|
||||
if (!records) return res.status(404).send(`No records found for ${domain}`);
|
||||
|
||||
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);
|
||||
return res.json({ skylink });
|
||||
|
|
19
yarn.lock
19
yarn.lock
|
@ -5734,24 +5734,7 @@ eslint-plugin-react-hooks@^1.7.0:
|
|||
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04"
|
||||
integrity sha512-iXTCFcOmlWvw4+TOE8CLWj6yX1GwzT0Y6cUfHHZqWnSk144VmVIRcVGtUAzrLES7C798lmvnt02C7rxaOX1HNA==
|
||||
|
||||
eslint-plugin-react@7.20.6:
|
||||
version "7.20.6"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.20.6.tgz#4d7845311a93c463493ccfa0a19c9c5d0fd69f60"
|
||||
integrity sha512-kidMTE5HAEBSLu23CUDvj8dc3LdBU0ri1scwHBZjI41oDv4tjsWZKU7MQccFzH1QYPYhsnTF2ovh7JlcIcmxgg==
|
||||
dependencies:
|
||||
array-includes "^3.1.1"
|
||||
array.prototype.flatmap "^1.2.3"
|
||||
doctrine "^2.1.0"
|
||||
has "^1.0.3"
|
||||
jsx-ast-utils "^2.4.1"
|
||||
object.entries "^1.1.2"
|
||||
object.fromentries "^2.0.2"
|
||||
object.values "^1.1.1"
|
||||
prop-types "^15.7.2"
|
||||
resolve "^1.17.0"
|
||||
string.prototype.matchall "^4.0.2"
|
||||
|
||||
eslint-plugin-react@^7.20.6:
|
||||
eslint-plugin-react@7.21.4, eslint-plugin-react@^7.20.6:
|
||||
version "7.21.4"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.21.4.tgz#31060b2e5ff82b12e24a3cc33edb7d12f904775c"
|
||||
integrity sha512-uHeQ8A0hg0ltNDXFu3qSfFqTNPXm1XithH6/SY318UX76CMj7Q599qWpgmMhVQyvhq36pm7qvoN3pb6/3jsTFg==
|
||||
|
|
Reference in New Issue