Skip to content

fix: res.location('back') alias, compat=4 .js mime type - #31

Merged
otnc merged 1 commit into
mainfrom
fix/v4-location-back-and-js-mime
Sep 11, 2026
Merged

otnc merged 1 commit into
mainfrom
fix/v4-location-back-and-js-mime

Conversation

@otnc

@otnc otnc commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • `res.location('back')`/`res.redirect('back')` was sent as the literal string 'back' instead of resolving to the Referrer/Referer header (falling back to '/'). Express 5 dropped this alias entirely -- a literal 'back' really is sent as-is there -- so this is compat=4 only.
  • `lookupMimeType('js')` returned `'text/javascript'` unconditionally. That's the current mime-db entry, but Express 4 predates the IANA/WHATWG registration change and used the older `'application/javascript'`. `withCharset()` also didn't know that type needed a charset appended (it only recognized `text/*`, `application/json` and `image/svg+xml`).

Based on `main` directly (not stacked on #30, which is still open) to keep this PR's scope independent.

Test plan

  • `node test/express-suite/run.js` -- 1108/8 unchanged (v5)
  • `node test/express-suite/run.js --v4` -- against main's own baseline (1198 total, 51 failing): 1151/47, 4 fewer failing, baseline updated
  • `pnpm run typecheck`
  • `pnpm run ci` (biome)
  • `pnpm run test` (vitest) -- 234 passing

Note

Per your instructions, this PR is not merged -- ready for your review.

- res.location('back')/res.redirect('back') was sent as the literal
  string 'back' instead of resolving to the Referrer/Referer header
  (falling back to '/'). Express 5 dropped this alias entirely -- a
  literal 'back' really is sent as-is there -- so this is compat=4 only.

- lookupMimeType('js') returned 'text/javascript' unconditionally.
  That's the current mime-db entry, but Express 4 predates the
  IANA/WHATWG registration change and used the older
  'application/javascript'. withCharset() also didn't know that type
  needed a charset appended (it only recognized text/*, application/json
  and image/svg+xml).

Express suite: 1108/8 unchanged (v5). 1151/47 -> ... this branch is off
main, so measured against main's own baseline (1198 total, 51 failing):
1151/47, 4 fewer failing.
@otnc
otnc merged commit 03b5a91 into main Sep 11, 2026
5 checks passed
@otnc
otnc deleted the fix/v4-location-back-and-js-mime branch September 11, 2026 16:43
otnc added a commit that referenced this pull request Sep 11, 2026
Resolves the conflict from #31 merging first (both touched
README.md's status line and the express-suite baseline). Numbers
recomputed by rerunning both suites fresh against the combined
source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant