Skip to content

Commit

Permalink
Fix a bug where a href "#" would crash feed outputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlangberg committed May 30, 2015
1 parent 7adedcf commit 3fdf3f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/goldwasher.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,17 @@ <h1 class="page-title">Source: goldwasher.js</h1>
href = domObject.next('a').attr('href');
}

// no valid href here, return url
if (href === '#') {
return url;
}

// check for relative URLs and append URL if relative
if (url &amp;&amp; href &amp;&amp; !v.isURL(href)) {
href = url + href;
}

// if still no href, just return url
if (!href) {
return url;
}
Expand Down Expand Up @@ -575,7 +581,7 @@ <h2><a href="index.html">Index</a></h2>
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sat May 30 2015 18:26:38 GMT+0200 (CEST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sat May 30 2015 23:38:18 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ <h2><a href="index.html">Index</a></h2>
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sat May 30 2015 18:26:38 GMT+0200 (CEST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sat May 30 2015 23:38:18 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
Expand Down
6 changes: 6 additions & 0 deletions lib/goldwasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ var getCheerioClosestHref = function(domObject, url) {
href = domObject.next('a').attr('href');
}

// no valid href here, return url
if (href === '#') {
return url;
}

// check for relative URLs and append URL if relative
if (url && href && !v.isURL(href)) {
href = url + href;
}

// if still no href, just return url
if (!href) {
return url;
}
Expand Down
1 change: 1 addition & 0 deletions test/goldwasher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var testContentMeta = '<html><head>' +
'<meta name="author" content="Baz Barfoo">' +
'</head><body>' +
testContentHref +
'<div><a href="#"><h1>invalid link</h1></a></div>' +
'</body></html>';
var testContentXml = '<?xml version="1.0" encoding="UTF-8"?>' +
'<foo><bar>' +
Expand Down

0 comments on commit 3fdf3f6

Please sign in to comment.