Skip to content
Permalink
Browse files

Validator rollup + fix #10

  • Loading branch information
pietergreyling committed Oct 9, 2017
1 parent bec248b commit 90a175f1f8486aac6cf1cd4c41ee293345a20d50
Showing with 13,279 additions and 6,898 deletions.
  1. +1 −0 .gitignore
  2. +8 −6 ampbench_handlers.js
  3. +7 −5 ampbench_lib.js
  4. +115 −62 ampbench_routes.js
  5. +12,826 −6,515 package-lock.json
  6. +322 −310 validator/validator.js
@@ -13,6 +13,7 @@
# put any other files you don't want to check in here,
# such as .DS_Store (OSX), *.bak, etc.
.DS_Store
public/.DS_Store

# Visual Studio Code
.vscode/*
@@ -24,7 +24,7 @@ const sdlib = require('./ampbench_lib_sd.js');
// app version
//

const VERSION_STRING = '[AMPBench:v.1.0]';
const VERSION_STRING = '[AMPBENCH:V.1.0]';

function version_msg(msg) {
return VERSION_STRING + '[' + new Date().toISOString() + '] ' + msg;
@@ -97,10 +97,7 @@ function validate(route, user_agent, user_agent_name, req, res, on_validate_call

const on_amp_validate = (http_response, output) => {

console.log(version_msg(
validator_signature() +
'[HTTP:' + http_response.http_response_code + '] ' +
req.path + ' ' + url_to_validate)); //!!!USEFUL!!!
// console.log(`### [http_response.statusIsOK: ${http_response.statusIsOK()}]`);

let parse_amplinks = benchlib.parse_page_content(http_response);

@@ -401,7 +398,9 @@ function validate(route, user_agent, user_agent_name, req, res, on_validate_call
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
response_timestamp: new Date().toISOString(), // The timezone is always zero UTC offset, as per suffix "Z"
amphtml_validator_signature: validator_signature().substr(0, 21+16) + ']', // only show left 16 chars
// http_response: http_response,
http_response: http_response,
http_response_code: http_response.http_response_code,
http_response_statusIsOK: http_response.statusIsOK(),
http_response_result: http_response_result,
parse_amplinks: parse_amplinks,
canonical_parsed_return: canonical_parsed_return,
@@ -465,6 +464,9 @@ function validate(route, user_agent, user_agent_name, req, res, on_validate_call

on_validate_callback(__ret); // DONE!!!
}

// console.log(`### [DANGLING!][http_response.statusIsOK: ${http_response.statusIsOK()}]`);

};
sdlib.check_image_urls_are_reachable(publisher_logo_url, article_image_url, on_check_image_urls_are_reachable);
};
@@ -940,12 +940,14 @@ function fetch_and_validate_url(validate_url, on_output_callback, as_json) {
http_response.setResponseEnded();
body = chunks.join('');
http_response.http_response_body = body;
if (0 == as_json) { // return output as JSON or not
output = lib_validate_lines(body, full_path); //!!!NOTE: gets a MULTILINE STRING
} else {
output = lib_validate_json(body, full_path); //!!!NOTE: gets an ARRAY
if (http_response.statusIsOK()) {
if (0 === as_json) { // return output as JSON or not
output = lib_validate_lines(body, full_path); //!!!NOTE: gets a MULTILINE STRING
} else {
output = lib_validate_json(body, full_path); //!!!NOTE: gets an ARRAY
}
on_output_callback(http_response, output); // !!! RETURN to front-end - - - - - - - - - - - - -
}
on_output_callback(http_response, output); // !!! RETURN to front-end - - - - - - - - - - - - -
});
};

0 comments on commit 90a175f

Please sign in to comment.
You can’t perform that action at this time.