A platform for community discussion. Free, open, simple.
FIX: add missing server-side-only routes to Ember router (#38962)
Régis Hanol7e8672332022
diff --git a/frontend/discourse/app/lib/url.js b/frontend/discourse/app/lib/url.jsindex b0b3fec0515..1e5a4d7a34f 100644--- a/frontend/discourse/app/lib/url.js+++ b/frontend/discourse/app/lib/url.js@@ -35,6 +35,14 @@ const SERVER_SIDE_ONLY = [/^\/pub\//,/^\/invites\//,/^\/styleguide/,+ /^\/safe-mode/,+ /^\/dev-mode/,+ /^\/theme-qunit/,+ /^\/llms\.txt$/,+ /^\/robots\.txt$/,+ /^\/offline\.html$/,+ /^\/manifest\.webmanifest$/,+ /^\/opensearch\.xml$/,];// The amount of height (in pixels) that we factor in when jumpEnd is called sodiff --git a/frontend/discourse/tests/unit/lib/url-test.js b/frontend/discourse/tests/unit/lib/url-test.jsindex cd95b89a426..a0e96f375b9 100644--- a/frontend/discourse/tests/unit/lib/url-test.js+++ b/frontend/discourse/tests/unit/lib/url-test.js@@ -358,6 +358,31 @@ module("Unit | Utility | url", function (hooks) {);});+ test("routeTo redirects server-side-only routes", async function (assert) {+ sinon.stub(DiscourseURL, "redirectTo");+ sinon.stub(DiscourseURL, "handleURL");++ const routes = [+ "/safe-mode",+ "/dev-mode",+ "/theme-qunit",+ "/llms.txt",+ "/robots.txt",+ "/offline.html",+ "/manifest.webmanifest",+ "/opensearch.xml",+ ];++ for (const route of routes) {+ DiscourseURL.redirectTo.resetHistory();+ DiscourseURL.routeTo(route);+ assert.true(+ DiscourseURL.redirectTo.calledWith(route),+ `${route} is redirected to server`+ );+ }+ });+test("anchor handling", async function (assert) {sinon.stub(DiscourseURL, "jumpToElement");sinon.stub(DiscourseURL, "replaceState");