Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ describe("QueryParamsRuleProcessor:", function () {
).toBe(URL_SOURCES.EXAMPLE + "?b=2");
});

it("should preserve equals signs in existing query param values", function () {
const addModification = {
type: CONSTANTS.MODIFICATION_TYPES.ADD,
param: "added",
value: "2",
};
const removeModification = {
type: CONSTANTS.MODIFICATION_TYPES.REMOVE,
param: "remove",
};
const url = URL_SOURCES.EXAMPLE + "?token=abc==&remove=1";

expect(QueryParamsRuleProcessor.applyQueryParamModifications([addModification], url)).toBe(
URL_SOURCES.EXAMPLE + "?token=abc==&remove=1&added=2"
);
expect(QueryParamsRuleProcessor.applyQueryParamModifications([removeModification], url)).toBe(
URL_SOURCES.EXAMPLE + "?token=abc=="
);
});

it("add and remove param should not create any effect", function () {
var modifications = queryParamsRule.pairs[0]["modifications"];

Expand Down
5 changes: 3 additions & 2 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ export function getQueryParamsMap(queryString) {
queryParams = queryString.split("&");

queryParams.forEach(function (queryParam) {
var paramName = queryParam.split("=")[0],
paramValue = queryParam.split("=")[1];
var separatorIndex = queryParam.indexOf("="),
paramName = separatorIndex === -1 ? queryParam : queryParam.slice(0, separatorIndex),
paramValue = separatorIndex === -1 ? undefined : queryParam.slice(separatorIndex + 1);

// We are keeping value of param as array so that in future we can support multiple param values of same name
// And we do not want to lose the params if url already contains multiple params of same name
Expand Down