Resolve relative web app manifest URLs #7

Merged
raucao merged 2 commits from fix/relative-manifest-url into master 2026-11-23 18:41:24 +00:00
Owner

The web client resolved relative link[rel=manifest] hrefs by naive string joining, so a page at https://rememorize.5apps.com with href="./manifest.webmanifest" produced https://rememorize.5apps.com/./manifest.webmanifest. That literal /./ path was sent to the server, and servers that do not normalise dot segments (5apps runs openresty) answered with 404. The manifest was never loaded, and metadata silently fell back to nothing.

This change resolves relative hrefs against the document URL with URI.join (RFC 3986), which collapses dot segments and also handles bare relative paths and nested document URLs correctly. Absolute manifest URLs are passed through unchanged, and icon src values are untouched.

A regression spec covers a page whose manifest href is ./manifest.webmanifest, asserting the manifest is fetched as a hash and that only the clean resolved URL is requested. WebMock normalises dot segments when matching requests, so the spec additionally captures the URL handed to the HTTP layer, keeping the regression meaningful.

Version bumped to 1.1.1. The bug was triggered in production by rememorize.5apps.com.

The web client resolved relative `link[rel=manifest]` hrefs by naive string joining, so a page at `https://rememorize.5apps.com` with `href="./manifest.webmanifest"` produced `https://rememorize.5apps.com/./manifest.webmanifest`. That literal `/./` path was sent to the server, and servers that do not normalise dot segments (5apps runs openresty) answered with 404. The manifest was never loaded, and metadata silently fell back to nothing. This change resolves relative hrefs against the document URL with `URI.join` (RFC 3986), which collapses dot segments and also handles bare relative paths and nested document URLs correctly. Absolute manifest URLs are passed through unchanged, and icon `src` values are untouched. A regression spec covers a page whose manifest href is `./manifest.webmanifest`, asserting the manifest is fetched as a hash and that only the clean resolved URL is requested. WebMock normalises dot segments when matching requests, so the spec additionally captures the URL handed to the HTTP layer, keeping the regression meaningful. Version bumped to 1.1.1. The bug was triggered in production by rememorize.5apps.com.
raucao added 1 commit 2026-11-23 18:33:18 +00:00
Resolve the manifest href against the document URL using URI.join
(RFC 3986) instead of naive string concatenation. The previous approach
produced URLs with dot segments like /./manifest.webmanifest, which
servers that do not normalise dot segments (e.g. 5apps/openresty)
reject with a 404, silently breaking manifest metadata.

Version 1.1.1.
raucao added 1 commit 2026-11-23 18:34:08 +00:00
raucao added the bug label 2026-11-23 18:40:04 +00:00
raucao merged commit 16bbdcbd5d into master 2026-11-23 18:41:24 +00:00
raucao deleted branch fix/relative-manifest-url 2026-11-23 18:41:25 +00:00
Sign in to join this conversation.