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
The library is CommonJS-compatible. You can `require("url.js")` in your files.
18
+
# urljs
43
19
20
+
A lightweight JavaScript library to manipulate the page url.
44
21
45
-
## :cloud: Installation
46
22
47
23
48
-
Check out the [`src`](/src) directory to download the needed files and include them on your page.
49
24
50
-
If you're using this module in a CommonJS environment, you can install it using `npm` or `yarn` and `require` it:
25
+
## Installation
51
26
52
27
```sh
53
-
# Using npm
54
-
npm install --save urljs
55
-
56
-
# Using yarn
57
-
yarn add urljs
28
+
$ npm i urljs
58
29
```
59
30
60
31
61
32
62
33
63
34
64
-
## :question: Get Help
65
35
66
-
There are few ways to get help:
67
36
68
-
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
69
-
2. For bug reports and feature requests, open issues. :bug:
70
37
71
38
72
39
73
40
74
-
## :memo: Documentation
41
+
42
+
43
+
44
+
45
+
46
+
## Documentation
47
+
48
+
49
+
75
50
76
51
77
52
### `queryString(name, notDecoded)`
78
53
Finds the value of parameter passed in first argument.
79
54
80
55
#### Params
81
-
82
56
-**String**`name`: The parameter name.
83
57
-**Boolean**`notDecoded`: If `true`, the result will be encoded.
84
58
@@ -92,7 +66,6 @@ the parameter is there, but it doesn't have a value, the value will
92
66
be `true`.
93
67
94
68
#### Params
95
-
96
69
-**String**`search`: An optional string that should be parsed (default: `window.location.search`).
97
70
98
71
#### Return
@@ -102,7 +75,6 @@ be `true`.
102
75
Stringifies a query object.
103
76
104
77
#### Params
105
-
106
78
-**Object**`queryObj`: The object that should be stringified.
107
79
108
80
#### Return
@@ -112,7 +84,6 @@ Stringifies a query object.
112
84
Adds, updates or deletes a parameter (without page refresh).
113
85
114
86
#### Params
115
-
116
87
-**String|Object**`param`: The parameter name or name-value pairs as object.
117
88
-**String**`value`: The parameter value. If `undefined`, the parameter will be removed.
118
89
-**Boolean**`push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
@@ -122,17 +93,19 @@ will not bring you to the old location.
122
93
#### Return
123
94
-**Url** The `Url` object.
124
95
125
-
### `getLocation()`
96
+
### `getLocation(excludeHash)`
126
97
Returns the page url, but not including the domain name.
127
98
99
+
#### Params
100
+
-**Boolean**`excludeHash`: If `true`, the location hash will not be appended in the result.
101
+
128
102
#### Return
129
103
-**String** The page url (without domain).
130
104
131
105
### `hash(newHash, triggerPopState)`
132
106
Sets/gets the hash value.
133
107
134
108
#### Params
135
-
136
109
-**String**`newHash`: The hash to set.
137
110
-**Boolean**`triggerPopState`: Triggers the popstate handlers (by default falsly).
138
111
@@ -143,7 +116,6 @@ Sets/gets the hash value.
143
116
Update the full url (pathname, search, hash).
144
117
145
118
#### Params
146
-
147
119
-**String**`s`: The new url to set.
148
120
-**Boolean**`push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
149
121
will not bring you to the old location.
@@ -157,7 +129,6 @@ pathname
157
129
Sets/gets the pathname.
158
130
159
131
#### Params
160
-
161
132
-**String**`pathname`: The pathname to set.
162
133
-**Boolean**`push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
163
134
will not bring you to the old location.
@@ -173,14 +144,12 @@ Calls the popstate handlers.
173
144
Adds a popstate handler.
174
145
175
146
#### Params
176
-
177
147
-**Function**`cb`: The callback function.
178
148
179
149
### `removeHash(push, trigger)`
180
150
Removes the hash from the url.
181
151
182
152
#### Params
183
-
184
153
-**Boolean**`push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
185
154
will not bring you to the old location.
186
155
-**Boolean**`trigger`: Triggers the popstate handlers (by default falsly).
@@ -189,23 +158,24 @@ will not bring you to the old location.
189
158
Removes the querystring parameters from the url.
190
159
191
160
#### Params
192
-
193
161
-**Boolean**`push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
194
162
will not bring you to the old location.
195
163
-**Boolean**`trigger`: Triggers the popstate handlers (by default falsly).
196
164
197
165
198
166
199
-
## :yum: How to contribute
167
+
168
+
169
+
170
+
## How to contribute
200
171
Have an idea? Found a bug? See [how to contribute][contributing].
0 commit comments