function(aUrlParams) {

					var aUrlParamsNormalized = [];

					var fnStartsWith = function(sValue) {
						var apostLocation = sValue.indexOf("'");
						var doubleQuotesLocation = sValue.indexOf("\"");
						if (apostLocation === -1 && doubleQuotesLocation === -1) {
							return null;
						} else {
							if (apostLocation > -1 && doubleQuotesLocation === -1) {
								return "appost";
							}
							if (doubleQuotesLocation > -1 && apostLocation === -1) {
								return "doublequotes";
							}
							if (apostLocation > -1 && doubleQuotesLocation > -1 && apostLocation < doubleQuotesLocation) {
								return "appost";
							}
							if (apostLocation > -1 && doubleQuotesLocation > -1 && doubleQuotesLocation < apostLocation) {
								return "doublequotes";
							}
						}

					};

					var fnAmpersandHandler = function(aParams, aParamsNorm, index, apostType) {
						var stringAmpersand = aParams[index];
						var j = index + 1;
						while (j < aParams.length && aParams[j].indexOf(apostType) === -1) {
							stringAmpersand = stringAmpersand + "&" + aParams[j];
							j++;
						}

						stringAmpersand = stringAmpersand + "&" + aParams[j];

						aParamsNorm.push(stringAmpersand);
						index = j;
						return index;
					};

					for (var i = 0; i < aUrlParams.length; i++) {
						// there is no ' and no " in param values
						if (!fnStartsWith(aUrlParams[i])) {
							aUrlParamsNormalized.push(aUrlParams[i]);
						}
						// there is ' in param value
						if (fnStartsWith(aUrlParams[i]) === "appost") {
							var firstLocation = aUrlParams[i].indexOf("'");
							if (aUrlParams[i].indexOf("'", firstLocation + 1) === -1) {
								i = fnAmpersandHandler(aUrlParams, aUrlParamsNormalized, i, "'");
							} else {
								aUrlParamsNormalized.push(aUrlParams[i]);
							}
						}
						// there is " in param value
						if (fnStartsWith(aUrlParams[i]) === "doublequotes") {
							var firstQuotesLocation = aUrlParams[i].indexOf("\"");
							if (aUrlParams[i].indexOf("\"", firstQuotesLocation + 1) === -1) {
								i = fnAmpersandHandler(aUrlParams, aUrlParamsNormalized, i, "\"");
							} else {
								aUrlParamsNormalized.push(aUrlParams[i]);
							}
						}
					}

					return aUrlParamsNormalized;
				}
function(aUrlParams) {

					var aUrlParamsNormalized = [];

					var fnStartsWith = function(sValue) {
						var apostLocation = sValue.indexOf("'");
						var doubleQuotesLocation = sValue.indexOf("\"");
						if (apostLocation === -1 && doubleQuotesLocation === -1) {
							return null;
						} else {
							if (apostLocation > -1 && doubleQuotesLocation === -1) {
								return "appost";
							}
							if (doubleQuotesLocation > -1 && apostLocation === -1) {
								return "doublequotes";
							}
							if (apostLocation > -1 && doubleQuotesLocation > -1 && apostLocation < doubleQuotesLocation) {
								return "appost";
							}
							if (apostLocation > -1 && doubleQuotesLocation > -1 && doubleQuotesLocation < apostLocation) {
								return "doublequotes";
							}
						}

					};

					var fnAmpersandHandler = function(aParams, aParamsNorm, index, apostType) {
						var stringAmpersand = aParams[index];
						var j = index + 1;
						while (j < aParams.length && aParams[j].indexOf(apostType) === -1) {
							stringAmpersand = stringAmpersand + "&" + aParams[j];
							j++;
						}

						stringAmpersand = stringAmpersand + "&" + aParams[j];

						aParamsNorm.push(stringAmpersand);
						index = j;
						return index;
					};

					for (var i = 0; i < aUrlParams.length; i++) {
						// there is no ' and no " in param values
						if (!fnStartsWith(aUrlParams[i])) {
							aUrlParamsNormalized.push(aUrlParams[i]);
						}
						// there is ' in param value
						if (fnStartsWith(aUrlParams[i]) === "appost") {
							var firstLocation = aUrlParams[i].indexOf("'");
							if (aUrlParams[i].indexOf("'", firstLocation + 1) === -1) {
								i = fnAmpersandHandler(aUrlParams, aUrlParamsNormalized, i, "'");
							} else {
								aUrlParamsNormalized.push(aUrlParams[i]);
							}
						}
						// there is " in param value
						if (fnStartsWith(aUrlParams[i]) === "doublequotes") {
							var firstQuotesLocation = aUrlParams[i].indexOf("\"");
							if (aUrlParams[i].indexOf("\"", firstQuotesLocation + 1) === -1) {
								i = fnAmpersandHandler(aUrlParams, aUrlParamsNormalized, i, "\"");
							} else {
								aUrlParamsNormalized.push(aUrlParams[i]);
							}
						}
					}

					return aUrlParamsNormalized;
				}
function ( aUrlParams ) { var aUrlParamsNormalized = [ ] ; var fnStartsWith = function ( sValue ) { var apostLocation = sValue . indexOf ( "'" ) ; var doubleQuotesLocation = sValue . indexOf ( "\"" ) ; if ( apostLocation === - 1 && doubleQuotesLocation === - 1 ) { return null ; } else { if ( apostLocation > - 1 && doubleQuotesLocation === - 1 ) { return "appost" ; } if ( doubleQuotesLocation > - 1 && apostLocation === - 1 ) { return "doublequotes" ; } if ( apostLocation > - 1 && doubleQuotesLocation > - 1 && apostLocation < doubleQuotesLocation ) { return "appost" ; } if ( apostLocation > - 1 && doubleQuotesLocation > - 1 && doubleQuotesLocation < apostLocation ) { return "doublequotes" ; } } } ; var fnAmpersandHandler = function ( aParams , aParamsNorm , index , apostType ) { var stringAmpersand = aParams [ index ] ; var j = index + 1 ; while ( j < aParams . length && aParams [ j ] . indexOf ( apostType ) === - 1 ) { stringAmpersand = stringAmpersand + "&" + aParams [ j ] ; j ++ ; } stringAmpersand = stringAmpersand + "&" + aParams [ j ] ; aParamsNorm . push ( stringAmpersand ) ; index = j ; return index ; } ; for ( var i = 0 ; i < aUrlParams . length ; i ++ ) { // there is no ' and no " in param values if ( ! fnStartsWith ( aUrlParams [ i ] ) ) { aUrlParamsNormalized . push ( aUrlParams [ i ] ) ; } // there is ' in param value if ( fnStartsWith ( aUrlParams [ i ] ) === "appost" ) { var firstLocation = aUrlParams [ i ] . indexOf ( "'" ) ; if ( aUrlParams [ i ] . indexOf ( "'" , firstLocation + 1 ) === - 1 ) { i = fnAmpersandHandler ( aUrlParams , aUrlParamsNormalized , i , "'" ) ; } else { aUrlParamsNormalized . push ( aUrlParams [ i ] ) ; } } // there is " in param value if ( fnStartsWith ( aUrlParams [ i ] ) === "doublequotes" ) { var firstQuotesLocation = aUrlParams [ i ] . indexOf ( "\"" ) ; if ( aUrlParams [ i ] . indexOf ( "\"" , firstQuotesLocation + 1 ) === - 1 ) { i = fnAmpersandHandler ( aUrlParams , aUrlParamsNormalized , i , "\"" ) ; } else { aUrlParamsNormalized . push ( aUrlParams [ i ] ) ; } } } return aUrlParamsNormalized ; }
helper to handle url param value with '&'
helper to handle url param value with &
This function is used to normalize a url params