* Validates a URL input, and logs the result to console. * @param {string} url * @async
(url)
| 216 | * @async |
| 217 | */ |
| 218 | async 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 | |
| 241 | goog.exportSymbol('amp.validator.init', init); |
| 242 | goog.exportSymbol('amp.validator.renderErrorMessage', renderErrorMessage); |
nothing calls this directly
no test coverage detected