Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1281 from Yoast/stories/escape-keyword-in-url
Browse files Browse the repository at this point in the history
Escape keyword in url and add spec
  • Loading branch information
xyfi authored Nov 7, 2017
2 parents 8648e6d + 5e34788 commit 016900b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spec/bundledPlugins/previouslyUsedKeywordsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ describe( "checks for keyword doubles", function(){
expect( plugin.scoreAssessment( {id: 0, count: 0}, paper, i18n ).score ).toBe( 9 );
expect( plugin.scoreAssessment( {id: 0, count: 0}, paper, i18n ).text ).toBe( "You've never used this focus keyword before, very good." );
});

it("escapes the keyword's special characters in the url", function(){
var paper = new Paper( "text", { keyword: "keyword/bla"} );
var plugin = new PreviouslyUsedKeywords( app, args, i18n );
expect( plugin.scoreAssessment({id: 1, count: 2 }, paper, i18n ).text ).toBe( "You've used this focus keyword <a href='http://search?keyword%2Fbla' target='_blank'>2 times before</a>, it's probably a good idea to read <a href='https://yoast.com/cornerstone-content-rank/' target='_blank'>this post on cornerstone content</a> and improve your keyword strategy." );
});
});

describe( "checks for keyword doubles", function(){
Expand Down
2 changes: 1 addition & 1 deletion src/bundledPlugins/previouslyUsedKeywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ PreviouslyUsedKeyword.prototype.scoreAssessment = function( previouslyUsedKeywor
};
}
if ( count > 1 ) {
url = "<a href='" + this.searchUrl.replace( "{keyword}", paper.getKeyword() ) + "' target='_blank'>";
url = "<a href='" + this.searchUrl.replace( "{keyword}", encodeURIComponent( paper.getKeyword() ) ) + "' target='_blank'>";
return {
/* Translators: %1$s and $3$s expand to the admin search page for the focus keyword, %2$d expands to the number of times this focus
keyword has been used before, %4$s and %5$s expand to a link to an article on yoast.com about cornerstone content */
Expand Down

0 comments on commit 016900b

Please sign in to comment.