mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #3607 from tgxworld/fix_%_in_url
FIX: Encode percent character in search terms.
This commit is contained in:
commit
487999ddc7
2 changed files with 15 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
import RestAdapter from 'discourse/adapters/rest';
|
||||
|
||||
function finderFor(filter, params) {
|
||||
export function finderFor(filter, params) {
|
||||
return function() {
|
||||
let url = Discourse.getURL("/") + filter + ".json";
|
||||
|
||||
|
@ -9,7 +9,7 @@ function finderFor(filter, params) {
|
|||
encoded = [];
|
||||
|
||||
keys.forEach(function(p) {
|
||||
const value = params[p];
|
||||
const value = encodeURI(params[p]);
|
||||
if (typeof value !== 'undefined') {
|
||||
encoded.push(p + "=" + value);
|
||||
}
|
||||
|
|
13
test/javascripts/adapaters/topic-list-test.js.es6
Normal file
13
test/javascripts/adapaters/topic-list-test.js.es6
Normal file
|
@ -0,0 +1,13 @@
|
|||
module("adapter:topic-list");
|
||||
|
||||
import { finderFor } from 'discourse/adapters/topic-list';
|
||||
|
||||
test("finderFor", function() {
|
||||
// Mocking instead of using a pretender which decodes the path and thus does
|
||||
// not reflect the behavior of an actual web server.
|
||||
var mock = sandbox.mock(Discourse);
|
||||
mock.expects("ajax").withArgs("/search.json?q=test%25%25");
|
||||
var finderForFunction = finderFor('search', { q: "test%%" });
|
||||
finderForFunction();
|
||||
mock.verify();
|
||||
});
|
Loading…
Reference in a new issue