Skip to content

Commit 725024e

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents af1f053 + 58de1b9 commit 725024e

File tree

12 files changed

+2396
-17
lines changed

12 files changed

+2396
-17
lines changed

assets/client.js

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,16 @@ function entityMatch(tag, handle) {
228228
}
229229

230230
function ipMatch(prefix, ip) {
231-
var ip = ipaddr.parse(ip);
232-
var prefix = ipaddr.parseCIDR(prefix);
233-
return (ip.kind() == prefix[0].kind() && ip.match(prefix));
231+
prefix = ipaddr.parseCIDR(prefix);
232+
if (ip.includes("/")) {
233+
ip = ipaddr.parseCIDR(ip);
234+
return (ip[0].kind() == prefix[0].kind() && ip[0].match(prefix));
235+
236+
} else {
237+
ip = ipaddr.parse(ip);
238+
return (ip.kind() == prefix[0].kind() && ip.match(prefix));
239+
240+
}
234241
}
235242

236243
// return the first HTTPS url, or the first URL
@@ -272,16 +279,24 @@ function showSpinner(msg) {
272279
div.appendChild(msgDiv);
273280
}
274281

282+
let lastQueriedURL = null;
283+
275284
// disable the user interface, initiate an XHR
276285
function sendQuery(url, followReferral=false, followingReferral=true) {
277286
freezeUI();
278287

288+
lastQueriedURL = null;
289+
279290
if (0 == url.indexOf('json://')) {
280291
// run the callback with a mock XHR
281-
handleResponse({
282-
"status": 200,
283-
"response": JSON.parse(url.substring(7))
284-
});
292+
handleResponse(
293+
{
294+
"status": 200,
295+
"response": JSON.parse(url.substring(7))
296+
},
297+
followReferral,
298+
followingReferral
299+
);
285300

286301
} else {
287302
let xhr = createXHR(url);
@@ -291,7 +306,7 @@ function sendQuery(url, followReferral=false, followingReferral=true) {
291306
handleError('Timeout performing query, please try again later.');
292307
};
293308

294-
xhr.onload = function() { handleResponse(xhr, followReferral); };
309+
xhr.onload = function() { handleResponse(xhr, followReferral, followingReferral); };
295310

296311
xhr.onreadystatechange = function() {
297312
if (4 == xhr.readyState && xhr.status < 1) {
@@ -339,9 +354,11 @@ function createErrorNode(error) {
339354
}
340355

341356
// callback executed when a response is received
342-
function handleResponse(xhr, followReferral=false) {
357+
function handleResponse(xhr, followReferral=false, followingReferral=false) {
343358
thawUI();
344359

360+
lastQueriedURL = xhr.responseURL;
361+
345362
if (404 == xhr.status) {
346363
handleError('This object does not exist.');
347364

@@ -364,7 +381,7 @@ function handleResponse(xhr, followReferral=false) {
364381
try {
365382
var div = document.getElementById('output-div');
366383
div.innerHTML = '';
367-
div.appendChild(processObject(xhr.response, true));
384+
div.appendChild(processObject(xhr.response, true, followReferral, followingReferral));
368385

369386
var url = document.createElement('a');
370387
url.href = window.location.href;
@@ -383,7 +400,7 @@ function handleResponse(xhr, followReferral=false) {
383400

384401
// process an RDAP object. Argument is a JSON object, return
385402
// value is an element that can be inserted into the page
386-
function processObject(object, toplevel, followReferral=true) {
403+
function processObject(object, toplevel, followReferral=true, followingReferral=false) {
387404
if (!object) {
388405
console.log(object);
389406
return false;
@@ -455,6 +472,28 @@ function processObject(object, toplevel, followReferral=true) {
455472
title.appendChild(document.createTextNode(titleText));
456473
card.appendChild(title);
457474

475+
if (toplevel) {
476+
const vbutton = document.createElement('button');
477+
vbutton.classList.add('btn', 'btn-link', 'btn-sm');
478+
vbutton.appendChild(document.createTextNode('Validate this record'));
479+
480+
vbutton.onclick = function() {
481+
const type = document.getElementById('type');
482+
const typeval = type.options[type.selectedIndex].value;
483+
484+
const url = 'https://validator.rdap.org/?' +
485+
'url=' + escape(lastQueriedURL) +
486+
'&response-type=' + escape('ip' === typeval ? 'ip network' : typeval);
487+
488+
window.open(url);
489+
};
490+
491+
// 160 = U+00A0 NO-BREAK SPACE
492+
title.appendChild(document.createTextNode(String.fromCharCode(160)));
493+
494+
title.appendChild(vbutton);
495+
}
496+
458497
var body = document.createElement('div');
459498
body.classList.add('card-body');
460499

@@ -849,7 +888,7 @@ function processVCardArray(vcard) {
849888
for (var i = 0 ; i < vcard.length ; i++) {
850889
var node = vcard[i];
851890

852-
var type = node[0];
891+
var type = node[0].toLowerCase();
853892
var value = node[3];
854893

855894
if ('version' == type) {
@@ -881,14 +920,19 @@ function processVCardArray(vcard) {
881920
} else if ('adr' == type) {
882921
type = 'Address';
883922

884-
if (node[1].label) {
923+
if (node[1].hasOwnProperty("label")) {
885924
var div = document.createElement('div');
886925
strings = node[1].label.split("\n");
887926
for (var j = 0 ; j < strings.length ; j++) {
888927
div.appendChild(document.createTextNode(strings[j]));
889928
if (j < strings.length - 1) div.appendChild(document.createElement('br'));
890929
}
891930

931+
if (node[1].hasOwnProperty("cc")) {
932+
div.appendChild(document.createElement('br'));
933+
div.appendChild(document.createTextNode(node[1].cc));
934+
}
935+
892936
value = div;
893937

894938
} else if (value) {
@@ -901,6 +945,10 @@ function processVCardArray(vcard) {
901945
}
902946
}
903947

948+
if (node[1].hasOwnProperty("cc")) {
949+
div.appendChild(document.createTextNode(node[1].cc));
950+
}
951+
904952
value = div;
905953
}
906954

assets/ipaddr.js/Changes.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### 2.2.0 - 2024-04-20
2+
3+
- add isValidCIDR method
4+
- fix parsing of some IPv4-embedded IPv6 adresses
5+
- add RFC7534, RFC7535, RFC7450, RFC6666, RFC5180, RFC7450 reserved address ranges
6+
7+
### 2.1.0 - 2023-05-23
8+
9+
- un-deprecate IPv6.toString() and make it an alias to toRFC5952String()
10+
- add reserved 198.18.0.0/15 block
11+
- add reserved blocks in 2001: space
12+
13+
14+
### 2.0.1 - 2020-01-06
15+
16+
- add support for deprecated IPv4 compatible IPv6 addresses #142
17+
- drop node 8 testing, add v14
18+
- fix parseInt for decimal, octal, hex
19+
- add support for classful (2,3 octet) IPv4
20+
21+
22+
### 2.0.0 - 2019-10-13
23+
24+
- use es6 templates instead of concatenated strings
25+
- lint: update tests with no-var
26+
- lint: allow no-cond-assign with extra parens
27+
- es6: replace var with const/let
28+
- update README with es6 examples #125
29+
- replace nodeunit with mocha
30+
- rewrite in JS, drop CoffeeScript
31+
32+
### 1.9.1 - 2019-07-03

0 commit comments

Comments
 (0)