[NIFI-3035] use URLSearchParams .toString() to update URL. This closes #1659

This commit is contained in:
Scott Aslan 2017-04-10 14:52:53 -04:00 committed by Matt Gilman
parent 68c592ea43
commit deed25656f
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
1 changed files with 5 additions and 11 deletions

View File

@ -410,27 +410,21 @@
params.set('processGroupId', groupId); params.set('processGroupId', groupId);
params.set('componentIds', selectedComponentIds.sort()); params.set('componentIds', selectedComponentIds.sort());
// create object whose keys are the parameter name and the values are the parameter values
var paramsObject = {};
params.forEach(function (v, k) {
paramsObject[k] = v;
});
var url = new URL(window.location); var url = new URL(window.location);
var newUrl = url.origin + url.pathname; var newUrl = url.origin + url.pathname;
if (nfCommon.isDefinedAndNotNull(nfCanvasUtils.getParentGroupId()) || selectedComponentIds.length > 0) { if (nfCommon.isDefinedAndNotNull(nfCanvasUtils.getParentGroupId()) || selectedComponentIds.length > 0) {
if (!nfCommon.isDefinedAndNotNull(nfCanvasUtils.getParentGroupId())) { if (!nfCommon.isDefinedAndNotNull(nfCanvasUtils.getParentGroupId())) {
// we are in the root group so set processGroupId param value to 'root' alias // we are in the root group so set processGroupId param value to 'root' alias
paramsObject['processGroupId'] = 'root'; params.set('processGroupId', 'root');
} }
if ((url.origin + url.pathname + '?' + $.param(paramsObject)).length <= nfCanvasUtils.MAX_URL_LENGTH) { if ((url.origin + url.pathname + '?' + params.toString()).length <= nfCanvasUtils.MAX_URL_LENGTH) {
newUrl = url.origin + url.pathname + '?' + $.param(paramsObject); newUrl = url.origin + url.pathname + '?' + params.toString();
} else if (nfCommon.isDefinedAndNotNull(nfCanvasUtils.getParentGroupId())) { } else if (nfCommon.isDefinedAndNotNull(nfCanvasUtils.getParentGroupId())) {
// silently remove all component ids // silently remove all component ids
paramsObject['componentIds'] = ''; params.set('componentIds', '');
newUrl = url.origin + url.pathname + '?' + $.param(paramsObject); newUrl = url.origin + url.pathname + '?' + params.toString();
} }
} }