Show domain name in unicode instead of ASCII on /dns/

parent 0e68df81
......@@ -17,10 +17,12 @@ function catcher(x) {
* Index
*/
router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
if(isIp(req.params.domain)) {
res.redirect(301, `/ip/${req.params.domain}`);
} else if(domainNameRegex.test(req.params.domain) || isDomainName(req.params.domain)) {
axios.get(`https://api.telcodb.net/v1/resolve?format=json&q=${req.params.domain}`)
const asciiDomain = req.params.domain;
if(isIp(asciiDomain)) {
res.redirect(301, `/ip/${asciiDomain}`);
} else if(domainNameRegex.test(asciiDomain) || isDomainName(asciiDomain)) {
axios.get(`https://api.telcodb.net/v1/resolve?format=json&q=${asciiDomain}`)
.then((response) => {
Promise.all([
getIpInfo(response.data).catch(catcher)
......@@ -32,11 +34,16 @@ router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
ipInfo = null;
}
const unicodeDomain = punycode.toUnicode(asciiDomain);
res.render("dns/show.twig", {
"title": `${req.params.domain} - DNS data`,
"title": `${unicodeDomain} - DNS data`,
"disable_title_prefix": true,
"canonical_url": `/dns/${asciiDomain}`,
"domain": req.params.domain,
"asciiDomain": asciiDomain,
"unicodeDomain": unicodeDomain,
"data": response.data,
......@@ -45,8 +52,8 @@ router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
});
})
.catch(next);
} else if(isIdn(req.params.domain)) {
res.redirect(`/dns/${punycode.toASCII(req.params.domain)}`)
} else if(isIdn(asciiDomain)) {
res.redirect(`/dns/${punycode.toASCII(asciiDomain)}`)
} else {
next();
}
......
{% extends 'layouts/default.twig' %}
{% block body %}
<h1>DNS data for {{ domain }}</h1>
<h1>DNS data for {{ unicodeDomain }}</h1>
{% if asciiDomain != unicodeDomain %}
<p>Punycode: <code>{{ asciiDomain }}</code></p>
{% endif %}
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
......@@ -98,8 +102,8 @@
{# <div class="tab-pane fade" id="website-info" role="tabpanel" aria-labelledby="website-info-tab">
<p class="mb-0"><strong>Alexa Rank</strong>: INSERT_ALEXA_RANK</p>
<img class="img-thumbnail" alt="Screenshot of {{ domain }}"
src="https://screenshots.lelux.fi/api/png?url=http://{{ domain }}" />
<img class="img-thumbnail" alt="Screenshot of {{ unicodeDomain }}"
src="https://screenshots.lelux.fi/api/png?url=http://{{ asciiDomain }}" />
</div> #}
{% endif %}
{% if ipInfo %}
......@@ -114,7 +118,7 @@
{% endblock %}
{% block javascripts %}
<script src="/assets/js/pages/dns/show/whois.js" data-query="{{ domain }}"></script>
<script src="/assets/js/pages/dns/show/whois.js" data-query="{{ asciiDomain }}"></script>
<script src="/assets/js/pages/dns/show/reverse-fetch.js" async defer></script>
{# <script src="/assets/js/pages/dns/show/ip-badge.js"></script> #}
{% endblock %}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment