MCPcopy Create free account
hub / github.com/binux/qiandao / defaultPath

Function defaultPath

web/static/node_components.js:282–303  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

280 * Assumption: the path (and not query part or absolute uri) is passed in.
281 */
282function 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

Callers 1

node_components.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected