I am reading query parameters using below method
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return '';
if (!results[2]) return '';
result = escape(results[2]);
return decodeURIComponent(result.replace(/\+/g, ' '));
URL is in below format http://loalhost:8080?param1=value1+value2
But problem with above method is if either in value1 and value2 contains genuine + character then that character also is replaced with space.
Can someone help me with this issue?
I need approach to solve above issue in plain javascript.