| 280 | * Assumption: the path (and not query part or absolute uri) is passed in. |
| 281 | */ |
| 282 | function defaultPath(path) { |
| 283 | // "2. If the uri-path is empty or if the first character of the uri-path is not |
| 284 | // a %x2F ("/") character, output %x2F ("/") and skip the remaining steps. |
| 285 | if (!path || path.substr(0,1) !== "/") { |
| 286 | return "/"; |
| 287 | } |
| 288 | |
| 289 | // "3. If the uri-path contains no more than one %x2F ("/") character, output |
| 290 | // %x2F ("/") and skip the remaining step." |
| 291 | if (path === "/") { |
| 292 | return path; |
| 293 | } |
| 294 | |
| 295 | var rightSlash = path.lastIndexOf("/"); |
| 296 | if (rightSlash === 0) { |
| 297 | return "/"; |
| 298 | } |
| 299 | |
| 300 | // "4. Output the characters of the uri-path from the first character up to, |
| 301 | // but not including, the right-most %x2F ("/")." |
| 302 | return path.slice(0, rightSlash); |
| 303 | } |
| 304 | |
| 305 | /* |
| 306 | * "A request-path path-matches a given cookie-path if at least one of the |