Git Product home page Git Product logo

w3c-link-validator's Introduction

Crawling algorithm flowchart

Join the chat at https://gitter.im/w3c-link-validator/Lobby GitHub license Build Status Coverage Status

Very good command line tool for W3C validation and broken link detection of your local development or production URL. Validation errors,warnings or suggestions will be reported to terminal.

Installation

Install with the terminal.

$ npm install w3c-link-validator -g

After installation w3clink command will be available globally.

Tutorial

Get started

See the command line help first.

$ w3clink --help
  Usage: w3clink [options]


  Options:

    -V, --version                                            output the version number
    check, --check <url> [verbose] [onlyhtml] [suggestions]  Validate links and html both
    -h, --help                                               output usage information

Validation command

$ w3clink check <url> [options]

This command will start validation service for specific URL. URLs per each page will be tested recursively.

Options

  • verbose will show you anything during the validation. Eg hyperlinks per page.
  • onlyhtml will block the deep url traversing. Use if you want to validate html standards only.
  • suggestions will log the suggestions also.

Example

$ w3clink check http://localhost/w3ctest/ suggestions

Sample output on Windows terminal

Sample terminal output

Massive websites may log bunch of messages to your terminal. Therefore you may save your log to a file.

 $ w3clink check http://localhost/w3ctest/ suggestions > mylogfile.txt

Contributing

Click here to view the full contribution guidelines

Development setup

Fork and clone repo

$ git clone https://github.com/<username>/w3c-link-validator.git

Install dependencies

$ npm install

Link to global commands

$ npm link

Run the tests

$ npm run test

Check the code coverage with istanbul. HTML report will be generated to /coverage/lcov-report

$ npm run coverage

Crawling algorithm

Crawling algorithm flowchart

Your contribution

We expect your contribution to improve this project. You may..

  • Open issues for bug reporting or new feature suggestions.
  • Submit pull requests from your fork in order to close existing issues.

We encourage you to apply Github best practices for the communication and development through the repo.

Happy contributing!

Acknowledgement

w3c-link-validator is initially developed for the Hacktitude open source hackathon. Special thanks goes to project mentors @thinkholic, @lakindu95, @rehrumesh and awesome Dotitude Family from 99xt.

License

MIT © 99XT

w3c-link-validator's People

Contributors

amilabgunarathne avatar chathuminavimukthi avatar gitter-badger avatar lakindu95 avatar padarom avatar shalithasuranga avatar sparcut avatar thinkholic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

w3c-link-validator's Issues

Code style

Would be great if there is a code style to follow. (eslint config?)

At the moment there is a mix, not sure which to follow.

E.g.

if(xyz){
     console.log(xyz);
}

or

if (xyz) {
    console.log(xyz);
}

etc.

Separate rulesets from validateHtml function.

Enhancement for clarity when finding rulesets. As rule arrays get larger, it would be best to modulize or at least move them out of the validateHtml function.

Thus, making it similar to find ruleset one is looking for when reading code.

TypeError: Path must be a string. Received null

Description

there's an error at each execution of the command line

HTML SUMMARY
✖ 7 problem(s) found

Adding 33 link(s) to the queue...



▶ http://localhost:8000/prices/single-product.html

BASE	single-product.html
STATUS	404 Not Found
ELAPSED	0.01 secs

❯ Checking HTML guidelines...


HTML SUMMARY
✔ no problem found

path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received null
    at assertPath (path.js:7:11)
    at Object.basename (path.js:1355:5)
    at runValidator (/usr/local/lib/node_modules/w3c-link-validator/src/w3clink.js:70:22)
    at Request._callback (/usr/local/lib/node_modules/w3c-link-validator/src/w3clink.js:117:13)
    at Request.self.callback (/usr/local/lib/node_modules/w3c-link-validator/node_modules/request/request.js:185:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/w3c-link-validator/node_modules/request/request.js:1157:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)

Steps to Reproduce

  1. npm install w3c-link-validator -g
  2. w3clink check http://localhost:8000

Expected behavior: no error

Actual behavior: error

Reproduces how often: every single time

Versions

Package: 1.0.0

npm: both 3.10.10 & 5.6.0

node: both 6.9.3 & 9.8.0

Fails on `mailto:` links

runValidator fails with an exception when a mailto: URL is found in the page. The application then terminates with:

internal/validators.js:112
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at validateString (internal/validators.js:112:11)
    at Object.basename (path.js:1157:5)
    at runValidator (/home/eon/eon-com-relaunch/node_modules/w3c-link-validator/src/w3clink.js:72:22)
    at Request._callback (/home/eon/eon-com-relaunch/node_modules/w3c-link-validator/src/w3clink.js:120:13)
    at Request.self.callback (/home/eon/eon-com-relaunch/node_modules/request/request.js:185:22)
    at Request.emit (events.js:210:5)
    at Request.<anonymous> (/home/eon/eon-com-relaunch/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:210:5)
    at IncomingMessage.<anonymous> (/home/eon/eon-com-relaunch/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:299:28) {
  code: 'ERR_INVALID_ARG_TYPE'
}

I have been able to resolve this by replacing

var _base = path.basename(urlinfo.pathname);

with

var _base = path.basename(urlinfo.pathname || urlinfo.href);

but I haven't really tested it.

Contributing docs

Add CONTRIBUTING.md to move current contribute info from README.md and add place for ruleset standards.

Currently working on PR. #52 ✔️

Links to style guide

Enhancement for user.

Add link to google/other styleguide per rule so the user can find a greater explanation of a rule. Thus, if the user doesn't understand the problem from the short explanation, they can view style guide itself that usually has example etc.

This could also be added to show when verbosity is turned up, though would take up a lot of space.

ocs/pull_request_template

  • I have tried looking for similar issues and I am sure this is a new issue.

Description

[Consise description of issue]

Steps to Reproduce

  1. [Step One]
  2. [Step Two]
  3. [and so on...]

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

Reproduces how often: [What percerage of the time does it reproduce?]

Versions

Please include package version (in package.json), npm version (npm -v), node version (node -v), OS and any other relevant software versions

Package: [0.0.0]

npm: [0.0.0]

node: [0.0.0]

Additional Information

[Any other infomation, configuration or data that might be necessary to reproduce this issue.]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.