-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from TAKANOME-DEV/fix-spaces-in-keyword
- Loading branch information
Showing
5 changed files
with
55 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const filterKeyword = require('../../src/utils/filterKeyword'); | ||
|
||
describe('Filter keyword function', () => { | ||
let keyword = ''; | ||
|
||
it('should replace the space with %20 in the keyword', () => { | ||
keyword = 'energy price'; | ||
const value = filterKeyword(keyword); | ||
expect(value).toBe('energy%20price'); | ||
}); | ||
|
||
it('should replace all the spaces with %20 in the keyword', () => { | ||
keyword = `electricity bill company firms`; | ||
const value = filterKeyword(keyword); | ||
expect(value).toBe('electricity%20bill%20company%20firms'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
//List of keywords | ||
module.exports = keywords = [ | ||
"green energy", | ||
"energy price", | ||
"energy prices", | ||
"energy firms", | ||
"renewable energy", | ||
"energy company", | ||
"energy tax", | ||
"energy bill", // new | ||
"energy resources", // new | ||
"electricity bill", // new | ||
"gas bill", // new | ||
"electricity costs", // new | ||
"energy", // new | ||
"gas prices", //new | ||
"petrol prices" //new | ||
'green energy', | ||
'energy price', | ||
'energy prices', | ||
'energy firms', | ||
'renewable energy', | ||
'energy company', | ||
'energy tax', | ||
'energy bill', // new | ||
'energy resources', // new | ||
'electricity bill', // new | ||
'gas bill', // new | ||
'electricity costs', // new | ||
'energy', // new | ||
'gas prices', //new | ||
'petrol prices', //new | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* | ||
* @param keyword the keyword to filter | ||
* @returns string where space is replaced by %20 | ||
*/ | ||
module.exports = function filterKeyword(keyword) { | ||
return keyword.replaceAll(/\s/g, '%20'); | ||
}; |