You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-14Lines changed: 10 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,15 @@
1
1
jQuery URL Parser v2.0
2
2
======================
3
3
4
-
A jQuery plugin to parse urls and provide easy access to their attributes (such as the protocol, host, port etc), path segments, query string paramters, fragment parameters and more.
4
+
A jQuery plugin to parse urls and provide easy access to their attributes (such as the protocol, host, port etc), path segments, querystring parameters, fragment parameters and more.
5
5
6
6
The core parser functionality is based on the [Regex URI parser by Steven Levithan](http://blog.stevenlevithan.com/archives/parseuri).
7
7
8
8
*Please note that version 2 is not backwards compatible with version 1 of this plugin. v1 is tagged and still available should you need it for some reason.*
9
9
10
10
This plugin requires jQuery to work. Tested on 1.4 and above but will probably work on older versions, too.
11
11
12
-
License
13
-
-------
14
-
15
-
http://unlicense.org/ - i.e. do what you want with it :-)
16
-
12
+
**License:**http://unlicense.org/ - i.e. do what you want with it :-)
17
13
18
14
Specifying the URL to parse
19
15
---------------------------
@@ -22,9 +18,7 @@ There are a few different ways to choose what URL to parse:
22
18
23
19
```javascript
24
20
var url =$.url(); // parse the current page URL
25
-
26
21
var url =$.url('http://allmarkedup.com'); // pass in a URI as a string and parse that
27
-
28
22
var url =$('#myElement').url(); // extract the URL from the selected element and parse that - will work on any element with a `src`, `href` or `action` attribute.
29
23
```
30
24
@@ -45,11 +39,11 @@ The attributes available for querying are:
45
39
***protocol** - eg. http, https, file, etc
46
40
***host** - eg. www.mydomain.com, localhost etc
47
41
***port** - eg. 80
48
-
***relative** - the relative path to the file including the query string (eg. /folder/dir/index.html?item=value)
42
+
***relative** - the relative path to the file including the querystring (eg. /folder/dir/index.html?item=value)
49
43
***path** - the path to the file (eg. /folder/dir/index.html)
50
44
***directory** - the directory part of the path (eg. /folder/dir/)
51
45
***file** - the basename of the file eg. index.html
52
-
***query** - the entire query string if it exists, eg. item=value&item2=value2
46
+
***query** - the entire querystring if it exists, eg. item=value&item2=value2
53
47
***fragment** (also available as **anchor**) - the entire string after the # symbol
54
48
55
49
There are also a few more obscure ones available too if you want to dig about a bit ;-)
@@ -59,20 +53,22 @@ If you don't specify an attribute then this method will return an object literal
59
53
Query string parameters
60
54
-----------------------
61
55
62
-
The `.param()` method is used to return the values of query string parameters.
56
+
The `.param()` method is used to return the values of querystring parameters.
63
57
64
58
Pass in a string to access that parameter's value:
Some sites and apps also use the hash fragment to store query string-style key value pairs (eg. `http://test.com/#sky=blue&grass=green`), or slash-delimited paths (eg. `http://test.com/#/about/us/`).
95
+
Some sites and apps also use the hash fragment to store querystring-style key value pairs (eg. `http://test.com/#sky=blue&grass=green`), or slash-delimited paths (eg. `http://test.com/#/about/us/`).
100
96
101
97
There are two methods available for extracting information from fragments of these types - `.fparam()` and `.fsegment()`, both of which behave indentically to their `.param()` and `.segment()` counterparts but act on the fragment rather than the main URL.
0 commit comments