INNER CODE UNIT · JavaScript
rfcPathMatch
expressjs/session · index.js:540
function rfcPathMatch(requestPath, cookiePath) {
// Normalize inputs (Node 0.8-safe)
requestPath = (typeof requestPath === 'string' && requestPath.length) ? requestPath : '/';
cookiePath = (typeof cookiePath === 'string' && cookiePath.length) ? cookiePath : '/';
// Root cookie matches everything
if (cookiePath === '/') return true;
// Exact match
if (requestPath === cookiePath) return true;
// Prefix match
if (requestPath.indexOf(cookiePath) === 0) {
// If cookiePath ends with '/', any longer requestPath is OK
if (cookiePath.charAt(cookiePath.length - 1) === '/') return true;
// Otherwise the next char after the prefix must be '/'
var nextChar = requestPath.length > cookiePath.length