DavidAnson / check-pages

Checks various aspects of a web page for correctness.
MIT License
11 stars 6 forks source link

dead link not picked up running checkDev task with gulp #8

Closed fivedoor closed 8 years ago

fivedoor commented 8 years ago

I am running the default ‘checkDev’ task with gulp on a basic html template. It picks up on some bad links e.g. that was an unresolved symbol: Bad link (404): http://localhost:8080/_UNSUBLINK__ (17ms) However some test dead links like http://www.deadlink-test.com were not picked up as inaccessible content in the console output which seemed odd.

Hosting the basic test template html and the stripped down gulp file here: https://jsfiddle.net/hp4dkn7f/

Full test repository here: https://github.com/fivedoor/frame-test-210716

Output:

Fivedoor-MacBook-Pro:frame-test fivedoor$ gulp checkDev
[15:12:40] Using gulpfile ~/Documents/development/frame-test/gulpfile.js
[15:12:41] Starting 'connect'...
[15:12:41] Finished 'connect' after 216 ms
[15:12:41] Starting 'watch'...
[15:12:41] Finished 'watch' after 34 ms
[15:12:41] Starting 'default'...
[15:12:41] Finished 'default' after 20 μs
[15:12:41] Starting 'checkDev'...
[15:12:45] Server started http://localhost:8080
[15:12:45] LiveReload started on port 35729
Checked 1 page and 2 links, found 24 issues.
Summary of issues:
 http://localhost:8080
  Unexpected close tag, Line: 12, Column: 7, Char: >
  Unexpected close tag, Line: 12, Column: 7, Char: >
  Unexpected close tag, Line: 12, Column: 7, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Unexpected close tag, Line: 49, Column: 49, Char: >
  Missing Content-Encoding header in response
 http://localhost:8080/
  Local link: http://localhost:8080/_UNSUBLINK__
  Bad link (404): http://localhost:8080/_UNSUBLINK__ (23ms)
  Local link: http://localhost:8080/_badlink__
  Bad link (404): http://localhost:8080/_badlink__ (9ms)

[15:12:45] 'checkDev' errored after 4.15 s
[15:12:45] Error: 24 issues.
    at /Users/fivedoor/Documents/development/frame-test/node_modules/check-pages/checkPages.js:426:13
    at next (/Users/fivedoor/Documents/development/frame-test/node_modules/check-pages/checkPages.js:435:5)
    at Request.<anonymous> (/Users/fivedoor/Documents/development/frame-test/node_modules/check-pages/checkPages.js:192:11)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/Users/fivedoor/Documents/development/frame-test/node_modules/check-pages/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at nextTickCallbackWith2Args (node.js:442:9)

Version details: • check-pages [ 0.10.0 ] • Node [ v4.4.3 ] • Npm [ 3.8.9 ] • OS X 10.11.4 • Gulp 3.9.1

Thanks

DavidAnson commented 8 years ago

Thanks! I'll have a look this weekend.

DavidAnson commented 8 years ago

The reason you don't get an error for the broken link http://www.deadlink-test.com is that you have the onlySameDomain option set to true which means that links on domains other than that of the test page (localhost in your scenario) should not be checked. Here's the documentation: https://github.com/DavidAnson/check-pages#onlysamedomain

Setting the option to false allows check-pages to check the link and it does report that it's broken, so I believe things are working correctly here. If you agree, I'll close the issue.

PS - While looking into this, I discovered and fixed an unrelated bug - so this was a good exercise! :)

fivedoor commented 8 years ago

Thanks very much David. Sorry to miss something so obvious. I think I must’ve burnt my brain cells out trying to troubleshoot the browserSync issue from the other post. If/when I get further feedback on that I will post an update.

Happy to close this issue. (Glad it had some use in terms of the bug fix.) Thanks for your help.