MCPcopy Create free account
hub / github.com/ampproject/amphtml / validateUrlAndLog

Function validateUrlAndLog

validator/cpp/engine/wasm/validator.js:218–239  ·  view source on GitHub ↗

* Validates a URL input, and logs the result to console. * @param {string} url * @async

(url)

Source from the content-addressed store, hash-verified

216 * @async
217 */
218async function validateUrlAndLog(url) {
219 asserts.assert(
220 isAmpCacheUrl(url) === false,
221 'Attempting to validate an AMP cache URL.' +
222 'Please use #development=1 on the origin URL instead.');
223 const [
224 response,
225 ] = await Promise.all([
226 fetch(url),
227 init(),
228 ]);
229 asserts.assert(response.status === 200, `Failed to fetch ${url}`);
230 const html = await response.text();
231 let format = 'AMP';
232 uriUtils.parseQueryData(uriUtils.getFragment(url), (key, value) => {
233 if (key === 'development') {
234 format = value === '1' ? 'AMP' : value;
235 }
236 });
237 const validationResult = validateString(html, format);
238 logValidationResult(validationResult, url);
239}
240
241goog.exportSymbol('amp.validator.init', init);
242goog.exportSymbol('amp.validator.renderErrorMessage', renderErrorMessage);

Callers

nothing calls this directly

Calls 8

isAmpCacheUrlFunction · 0.85
fetchFunction · 0.85
validateStringFunction · 0.85
assertMethod · 0.80
initFunction · 0.70
logValidationResultFunction · 0.70
textMethod · 0.45
getFragmentMethod · 0.45

Tested by

no test coverage detected