Commit 0d672597 authored by Kingdutch's avatar Kingdutch

by Kingdutch: Don't break snippet title when keyword is not found

The keyword highlighter still tried to highlight the keyword if it
didn't exist in the snippet title, leading to a malformed display.
parent da611e33
......@@ -326,7 +326,10 @@
if (this.data.keyword) {
var keyword_pos = this.data.metaTitle.toLowerCase().indexOf(this.data.keyword.toLowerCase());
var keyword_length = this.data.keyword.length;
emphasized_title = this.data.metaTitle.substr(0, keyword_pos) + '<strong>' + this.data.metaTitle.substr(keyword_pos, keyword_length) + '</strong>' + this.data.metaTitle.substr(keyword_pos + keyword_length);
if (keyword_pos > -1 && keyword_length > 0) {
emphasized_title = this.data.metaTitle.substr(0, keyword_pos) + '<strong>' + this.data.metaTitle.substr(keyword_pos, keyword_length) + '</strong>' + this.data.metaTitle.substr(keyword_pos + keyword_length);
}
}
var html =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment