Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicann committed Jun 11, 2024
1 parent a2483c1 commit 3309bdc
Show file tree
Hide file tree
Showing 4 changed files with 765 additions and 102 deletions.
38 changes: 22 additions & 16 deletions bin/rdap-validator
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ for (var i = 2 ; i < process.argv.length ; i++) {

const url = opt.positional.shift();
const responseType = opt.named.type ?? "domain";
const serverType = opt.named["server-type"] ?? "thick-gtld-registry";
const serverType = opt.named["server-type"] ?? "vanilla";

import rdapValidator from "../lib/rdap-validator.js";
import XMLHttpRequest from "xmlhttprequest";
Expand All @@ -42,33 +42,39 @@ const jsonResultData = {

rdapValidator.setXHR(XMLHttpRequest.XMLHttpRequest);

const cliResultCallback = function(result, message, context) {
let lastPath = null;

if (true !== result && false !== result) {
console.log("\x1b[1;33mi\x1b[0m " + message);
const cliResultCallback = function(result, message, context, path) {
const indentString = " ";
const onlyErrors = opt.named.hasOwnProperty("only-errors");
const indent = indentString.repeat(onlyErrors ? 0 : Math.max(0, rdapValidator.path.length-1));

} else {
if (result) {
if (!opt.named.hasOwnProperty("only-errors")) {
console.log("\x1b[1;32m✓\x1b[0m " + message);
}
if (false === result) {
message = message + " (" + path + ")";

} else {
console.log("\x1b[1;31m✘\x1b[0m " + message);
console.log(indent + "\x1b[1;31m✘\x1b[0m " + message);

if (context !== undefined) {
console.log("\n" + indentString + indentString + indent + JSON.stringify(context, null, 2).trimEnd().replaceAll("\n", "\n" + indentString + indentString + indent) + "\n");
}
}

if (!result && context !== undefined) {
console.log("\n "+JSON.stringify(context, null, 2).trimEnd().replaceAll("\n", "\n ") + "\n");
} else if (false === onlyErrors) {
if (true === result) {
console.log(indent + "\x1b[1;32m✓\x1b[0m " + message);

} else {
console.log(indent + "\x1b[1;33mi\x1b[0m " + message);

}
}
};

const jsonResultCallback = function(result, message, context) {
const jsonResultCallback = function(result, message, context, path) {
jsonResultData.results.push({
result: result,
testPassed: result,
message: message,
context: context,
path: path,
});
};

Expand Down
Loading

0 comments on commit 3309bdc

Please sign in to comment.