( url, strictMode )
| 195 | } |
| 196 | |
| 197 | function purl( url, strictMode ) { |
| 198 | if ( arguments.length === 1 && url === true ) { |
| 199 | strictMode = true; |
| 200 | url = undefined; |
| 201 | } |
| 202 | strictMode = strictMode || false; |
| 203 | url = url || window.location.toString(); |
| 204 | |
| 205 | return { |
| 206 | |
| 207 | data : parseUri(url, strictMode), |
| 208 | |
| 209 | // get various attributes from the URI |
| 210 | attr : function( attr ) { |
| 211 | attr = aliases[attr] || attr; |
| 212 | return typeof attr !== 'undefined' ? this.data.attr[attr] : this.data.attr; |
| 213 | }, |
| 214 | |
| 215 | // return query string parameters |
| 216 | param : function( param ) { |
| 217 | return typeof param !== 'undefined' ? this.data.param.query[param] : this.data.param.query; |
| 218 | }, |
| 219 | |
| 220 | // return fragment parameters |
| 221 | fparam : function( param ) { |
| 222 | return typeof param !== 'undefined' ? this.data.param.fragment[param] : this.data.param.fragment; |
| 223 | }, |
| 224 | |
| 225 | // return path segments |
| 226 | segment : function( seg ) { |
| 227 | if ( typeof seg === 'undefined' ) { |
| 228 | return this.data.seg.path; |
| 229 | } else { |
| 230 | seg = seg < 0 ? this.data.seg.path.length + seg : seg - 1; // negative segments count from the end |
| 231 | return this.data.seg.path[seg]; |
| 232 | } |
| 233 | }, |
| 234 | |
| 235 | // return fragment segments |
| 236 | fsegment : function( seg ) { |
| 237 | if ( typeof seg === 'undefined' ) { |
| 238 | return this.data.seg.fragment; |
| 239 | } else { |
| 240 | seg = seg < 0 ? this.data.seg.fragment.length + seg : seg - 1; // negative segments count from the end |
| 241 | return this.data.seg.fragment[seg]; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | }; |
| 246 | |
| 247 | } |
| 248 | |
| 249 | purl.jQuery = function($){ |
| 250 | if ($ != null) { |
no test coverage detected
searching dependent graphs…