openvibers/openvibe.blog Commits

Blog: the navbar's sign-in link carries the path only too (#116)

OP OpenVibers committed 15 days ago · 22b28171cc · 1 file, +3 −1

The gate page was fixed to link to the path, but the shared navbar fills its own sign-in link
from the page's path — which several callers pass as the whole requested URL — so a signed-out
page still echoed its query string in the header. The layout now takes the path part.

Changes

ddiff --git a/server/render/layout.js b/server/render/layout.js
iindex eb2eb04..5351bba 100644
---- a/server/render/layout.js
++++ b/server/render/layout.js
@@@ -54,7 +54,9 @@ function renderPage(o) {
if (!o.decision) throw new TypeError('renderPage needs the gate decision');
const viewer = o.viewer || { kind: 'anonymous' };
const signedIn = viewer.kind === 'user';
-- const loginNext = encodeURIComponent(o.path || '/');
++ // The path only: o.path can be the whole requested URL, and a sign-in link that echoed its query would put
++ // a page's words into every page of the site, including the 401 a signed-out visitor sees (SEO-7 review).
++ const loginNext = encodeURIComponent(String(o.path || '/').split('?')[0] || '/');
const nav = {
service: 'blog',
apiBase: NETWORK_URL,