Jquery url builder / parser

I am looking for a jquery plugin for complete URL processing (parsing, creating).

Example:

var url = 'http://mypage.com/?param=1' var params = $.getParams(url) # {param: 1} var newUrl = $.newUrl(url, {param:2}) # 'http://mypage.com/?param=2' 

thanks.

+8
javascript jquery url parsing building
source share
2 answers

There is this jquery plugin https://github.com/allmarkedup/jQuery-URL-Parser , which I used once. But as soon as you console.log window.location , you will see that this is not so difficult.

I have never tried this one: http://urldecoderonline.com/javascript-url-decode-jquery-plugin.htm , but it looks like it can create a url.

Good luck

+4
source share

To convert a JavaScript object to a URL parameter string, you can use the jQuery param method:

 $.param({a:1, b:"Test 1"}) // gets: "a=1&b=Test+1" 

To parse the URL parameter string in a JavaScript object, use this solution .

+34
source share

Source: https://habr.com/ru/post/649786/


All Articles