url.getProtocol() | Get protocol | https |
url.getDomain() | Get domain | example.com |
url.getDomainWithPort() | Get domain with port | example.com:3000 |
url.getPort() | Get port | 3000 |
url.getPath() | Get path | /some-path |
url.getQuery() | Get query | x1=b |
url.getFragment() | Get fragment | foo |
url.getUri() | Get full URI with everything | https://example.come/some-path?x1=b#foo |
url.getUri() | Get full URI without protocol, domain, or port | /some-path?x1=b#foo |
url.get(variable<sub>*</sub>) | Get value of x1 from query url.get("x1") | some-string-value |
url.getAll(variable<sub>*</sub>) | Get values of x1 from query. Always returns an array. url.getAll("x1") | [] , ["value"] , ["a", "b"] |
url.removeQuery(variablesToKeep) | Remove query from URI. May pass in optional array of variables to keep: url.removeQuery(["x1"]) | url object to chain more methods. |
url.removeFragment() | Remove fragment from URI | url object to chain more methods. |
url.removePath() | Remove path from URI | url object to chain more methods. |
url.setPath(value<sub>*</sub>, doKeepQuery) | Set path & either keep rest of query/fragment or not. Default is not. url.setPath("/about", true) | url object to chain more methods. |
url.setFragment(value<sub>*</sub>) | Set new value for fragment. May be any falsy value or string. url.setFragment('title') | url object to chain more methods. |
url.set(variable<sub>*</sub>, value<sub>*</sub>) | Set value of variable in url url.set("x1", "y") | url object to chain more methods. |
url.add(variable<sub>*</sub>, value<sub>*</sub>) | Add one more value or set 1st value for the variable in url. url.add("tag", "foo") | url object to chain more methods. |
url.subtract(variable<sub>*</sub>, value<sub>*</sub>) | Subtract one value from the variable in url. url.subtract("tag", "foo") | url object to chain more methods. |
url.delete(variable<sub>*</sub>) | Delete single or multiple values of the variable. url.delete("tag", "foo") | url object to chain more methods. |
url.push() | Set URI at browser's address input and push history event to browser's history | url object to chain more methods. |
url.replace() | Set URI at browser's address input and replace current history event with new at browser's history | url object to chain more methods. |