Skip to content

Windows Infinite 302 Redirection #260

@nashaofu

Description

@nashaofu

return path.normalize(pieces.map((rawPiece) => {
const piece = decodeURIComponent(rawPiece);
if (process.platform === 'win32' && /\\/.test(piece)) {
throw new Error('Invalid forward slash character');
}
return piece;
}).join('/'));

Windows pathname parsing is incorrect

if (!pathname.match(/\/$/)) {
res.statusCode = 302;
const q = parsed.query ? `?${parsed.query}` : '';
res.setHeader('location', `${parsed.pathname}/${q}`);
res.end();
return;
}

Or modify here to

if (!parsed.pathname.match(/\/$/)) {
  res.statusCode = 302;
  const q = parsed.query ? `?${parsed.query}` : '';
  res.setHeader('location', `${parsed.pathname}/${q}`);
  res.end();
  return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions