Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amphtml-validator

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amphtml-validator - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

16

index_test.js

@@ -143,2 +143,18 @@ #!/usr/bin/env node

it('also works with newInstance', function() {
var mini = fs.readFileSync(
'../testdata/feature_tests/minimum_valid_amp.html', 'utf-8');
var validatorJsContents =
fs.readFileSync('../dist/validator_minified.js', 'utf-8');
var resultForMini =
ampValidator.newInstance(validatorJsContents).validateString(mini);
expect(resultForMini.status).toBe('PASS');
var severalErrorsHtml =
fs.readFileSync('../testdata/feature_tests/several_errors.html', 'utf-8');
var resultForSeveralErrors = ampValidator.newInstance(validatorJsContents)
.validateString(severalErrorsHtml);
expect(resultForSeveralErrors.status).toBe('FAIL');
});
it('emits text if --format=text is specified on command line', function(done) {

@@ -145,0 +161,0 @@ var severalErrorsOut =

29

index.js

@@ -33,3 +33,2 @@ #!/usr/bin/env node

var VERSION = '0.1.0';
var DEFAULT_USER_AGENT = 'amphtml-validator';

@@ -295,2 +294,8 @@

/**
* Provided a URL or a filename from which to fetch the validator.js
* file, fetches, instantiates, and caches the validator instance
* asynchronously. If you prefer to implement your own fetching /
* caching logic, you may want to consider createInstance() instead,
* which is synchronous and much simpler.
*
* @param {string=} opt_validatorJs

@@ -304,4 +309,3 @@ * @param {string=} opt_userAgent

opt_validatorJs || 'https://cdn.ampproject.org/v0/validator.js';
var userAgent =
opt_userAgent || DEFAULT_USER_AGENT;
var userAgent = opt_userAgent || DEFAULT_USER_AGENT;
if (instanceByValidatorJs.hasOwnProperty(validatorJs)) {

@@ -331,2 +335,19 @@ return Promise.resolve(instanceByValidatorJs[validatorJs]);

/**
* Provided the contents of the validator.js file, e.g. as downloaded from
* 'https://cdn.ampproject.org/v0/validator.js', returns a new validator
* instance. The tradeoff between this function and getInstance() is that this
* function is synchronous but requires the contents of the validator.js
* file as a parameter, while getInstance is asynchronous, fetches files
* from disk or the web, and caches them.
*
* @param {string} validatorJsContents
* @returns {!Validator}
* @export
*/
function newInstance(validatorJsContents) {
return new Validator(validatorJsContents);
}
exports.newInstance = newInstance;
/**
* Logs a validation result to the console using console.log, console.warn,

@@ -366,3 +387,3 @@ * and console.error as is appropriate.

function main() {
program.version(VERSION)
program
.usage(

@@ -369,0 +390,0 @@ '[options] <fileOrUrlOrMinus...>\n\n' +

2

package.json
{
"name": "amphtml-validator",
"version": "1.0.12",
"version": "1.0.13",
"description": "Validator for AMP HTML (www.ampproject.org)",

@@ -5,0 +5,0 @@ "engines": {

@@ -57,1 +57,4 @@ # amphtml-validator Node.js Package

* Added support for --user-agent option
### 1.0.13
* Added newInstance method, a simple API that's not async.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc