Skip to content

Commit

Permalink
Canonicals must be non-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
john-kurkowski committed Mar 22, 2012
1 parent 5838275 commit 41baa09
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ trait ContentExtractor {
* if the article has meta canonical link set in the url
*/
def getCanonicalLink(article: Article): String = {
val meta = article.doc.select("link[rel=canonical]");
val meta = article.doc.select("link[rel=canonical]")
if (meta.size() > 0) {
val href = meta.first().attr("href");
if (string.isNullOrEmpty(href)) string.empty else href.trim()
val href = Option(meta.first().attr("href")).getOrElse("").trim
if (href.nonEmpty) href else article.finalUrl
} else {
article.finalUrl;
article.finalUrl
}
}

Expand Down

0 comments on commit 41baa09

Please sign in to comment.