(function () {
  const path = window.location.pathname;
  const match = path.match(/^\/download\/pdf\/(.+\.pdf)$/i);

  if (match) {
    const filePath = match[1];
    const redirectTo = '/index.php?route=common/pdf_viewer&file=' + encodeURIComponent(filePath);
    window.location.replace(redirectTo);
  }
})();