Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TelcoDB
Web Frontend
Commits
d24aa129
Verified
Commit
d24aa129
authored
Oct 22, 2019
by
Elias Ojala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle punycode on /tld/
parent
f7c74421
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
6 deletions
+37
-6
package.json
package.json
+1
-0
src/app.ts
src/app.ts
+22
-3
src/controllers/tld.controller.ts
src/controllers/tld.controller.ts
+3
-1
views/tld/list.twig
views/tld/list.twig
+2
-2
views/tld/show.twig
views/tld/show.twig
+4
-0
yarn.lock
yarn.lock
+5
-0
No files found.
package.json
View file @
d24aa129
...
...
@@ -41,6 +41,7 @@
"
jquery
"
:
"
^3.4.1
"
,
"
lusca
"
:
"
^1.6.1
"
,
"
path
"
:
"
^0.12.7
"
,
"
punycode
"
:
"
^2.1.1
"
,
"
svg-country-flags
"
:
"
^1.2.6
"
,
"
twig
"
:
"
^1.13.3
"
,
"
typescript
"
:
"
^3.6.2
"
...
...
src/app.ts
View file @
d24aa129
...
...
@@ -64,6 +64,11 @@ twig.extendFunction("getReverse", (ipAddr: string): string => {
return
""
;
})
import
punycode
from
"
punycode
"
;
twig
.
extendFunction
(
"
punycodeToASCII
"
,
(
input
:
string
):
string
=>
{
return
punycode
.
toASCII
(
input
);
});
/**
* Is server in production mode?
*/
...
...
@@ -233,7 +238,7 @@ twig.extendFunction("getBadge", (badgeName: string, asn?: number, pdb?, pdbDataT
});
function
getCountryName
(
countryCode
)
{
function
getCountryName
(
countryCode
,
returnSame
?
)
{
countryCode
=
countryCode
.
toUpperCase
();
if
(
countryCode
===
"
EU
"
)
{
return
"
European Union
"
;
...
...
@@ -247,6 +252,10 @@ function getCountryName(countryCode) {
countryName
=
country
.
name
;
}
catch
{}
if
(
returnSame
===
"
no
"
&&
countryName
==
countryCode
)
{
return
;
}
return
countryName
;
}
...
...
@@ -254,9 +263,19 @@ function getCountryName(countryCode) {
* UI feature:
* ISO 3166-1 alpha-2 to English
* aka "Get country code"
*
* If "returnSame" is not "no" and country is not found, the query is returned
*/
twig
.
extendFunction
(
"
countryCode
"
,
(
countryCode
)
=>
{
return
getCountryName
(
countryCode
);
twig
.
extendFunction
(
"
countryCode
"
,
(
countryCode
,
returnSame
?,
addParenthesis
?)
=>
{
const
result
=
getCountryName
(
countryCode
,
returnSame
);
if
(
addParenthesis
===
"
yes
"
&&
result
!=
undefined
)
{
return
`(
${
result
}
)`
;
}
else
if
(
result
!=
undefined
)
{
return
;
}
return
result
;
})
/**
...
...
src/controllers/tld.controller.ts
View file @
d24aa129
import
{
NextFunction
,
Request
,
Response
,
Router
}
from
"
express
"
;
import
axios
from
"
axios
"
;
import
isDomainName
from
"
is-domain-name
"
;
import
punycode
from
"
punycode
"
;
const
{
Resolver
}
=
require
(
'
dns
'
).
promises
;
const
resolver
=
new
Resolver
();
...
...
@@ -92,9 +93,10 @@ router.get("/:tld", (req: Request, res: Response, next: NextFunction) => {
.
then
(
nameserverAddresses
=>
{
res
.
render
(
"
tld/show.twig
"
,
{
"
canonical_url
"
:
`/tld/
${
tld
}
`
,
"
title
"
:
`Information about .
${
tld
}
`
,
"
title
"
:
`Information about .
${
punycode
.
toUnicode
(
tld
)
}
`
,
"
tld
"
:
tld
,
"
tldUnicode
"
:
punycode
.
toUnicode
(
tld
),
"
nameservers
"
:
nameservers
,
...
...
views/tld/list.twig
View file @
d24aa129
...
...
@@ -12,11 +12,11 @@
{%
else
%}
<li>
<a
href=
"/tld/
{{
domain
}}
"
>
<a
href=
"/tld/
{{
punycodeToASCII
(
domain
)
}}
"
>
{{
domain
}}
</a>
{%
if
domain
|
length
==
2
%}
(
{{
countryCode
(
domain
)
}}
)
{{
countryCode
(
domain
,
"no"
,
"yes"
)
}}
{%
endif
%}
</li>
...
...
views/tld/show.twig
View file @
d24aa129
...
...
@@ -3,6 +3,10 @@
{%
block
body
%}
<h1>
{{
title
}}
</h1>
{%
if
tldUnicode
!=
tld
%}
<p>
Punycode:
<code>
.
{{
tld
}}
</code></p>
{%
endif
%}
<h2>
Nameservers
</h2>
<table
class=
"table w-auto"
>
<thead>
...
...
yarn.lock
View file @
d24aa129
...
...
@@ -2874,6 +2874,11 @@ pstree.remy@^1.1.6:
resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.7.tgz#c76963a28047ed61542dc361aa26ee55a7fa15f3"
integrity sha512-xsMgrUwRpuGskEzBFkH8NmTimbZ5PcPup0LA8JJkHIm2IMUbQcpo3yeLNWVrufEYjh8YwtSVh0xz6UeWc5Oh5A==
punycode@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
qs@6.7.0:
version "6.7.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment