Tuesday, November 19, 2019

Use regexp to filter for question mark (?) parameter in url and add either ? or &

1.
var searchString = action + ((action.indexOf('?') == -1) ? '?search=' : '&search=');

2.
var startChar = action.indexOf('?') == -1 ? '?' : '&',
    searchString = action +  startChar  + 'search=' + search + '&filter=';

3.
var hasQM = (/\?/).test(action);
var searchString = action + (!hasQM ? '?' : '&') + 'search=' + search + '&filter='

No comments:

Post a Comment

Mixed Content: The page at xxx was loaded over HTTPS, but requested an insecure

 Mixed Content: The page at ' https ://www.test.com/signup.aspx' was loaded over HTTPS, but requested an insecure script ' http ...