Skip to content

Windows Infinite 302 Redirection #260

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;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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