Skip to content

Commit

Opening a doc from inside the app works again. Since yesterday a doc's page sent any request whose address was not the doc's own to the current address, meant for a doc renamed since; a navigation inside the app asks for the page's data at that same address with .data on the end, which the rule took for an old address and sent back to itself, so clicking a doc never landed while opening its address directly did. The rule now reads the address a navigation asks for as the page's own, and the history page's rule the same.

syntaqxcommitted Parentad5d495Browse files
2 files+9−30/2 viewed
+7−2
5656 if (found.error.code === "not_found" || found.error.code === "forbidden") return data<Loaded>({ denied: id }, { status: 403 });
5757 throw data(null, { status: 503 });
5858 }
59− // An old address (renamed since) goes to the current one.
59+ // An old address (renamed since) goes to the current one. A navigation
60+ // in the app asks for the page's data at the same path with `.data` on
61+ // the end: that is this address, not an old one.
6062 const url = new URL(request.url);
61− if (url.pathname !== found.value.folio.path) throw redirect(`${found.value.folio.path}${url.search}`);
63+ if (url.pathname.replace(/\.data$/, "") !== found.value.folio.path) {
64+ url.searchParams.delete("_routes");
65+ throw redirect(`${found.value.folio.path}${url.search}`);
66+ }
6267 return { page: found.value, ticket } as Loaded;
6368 }
6469
+2−1
2828 const [folio, versions] = await Promise.all([folios.folio(slug, viewer, id), folios.versions(slug, viewer, id)]);
2929 if (!folio.ok || !versions.ok) throw data(null, { status: 404 });
3030 const url = new URL(request.url);
31− if (url.pathname !== `${folio.value.path}/history`) throw redirect(`${folio.value.path}/history`);
31+ // A navigation in the app asks for this page's data with `.data` on the end: the same address.
32+ if (url.pathname.replace(/\.data$/, "") !== `${folio.value.path}/history`) throw redirect(`${folio.value.path}/history`);
3233 return { folio: folio.value, versions: versions.value };
3334 }
3435