mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
FIX: avoid eager rewrite of /my* routes (#23011)
This commit is contained in:
parent
b7953b2562
commit
904ab8deaa
@ -227,14 +227,14 @@ const DiscourseURL = EmberObject.extend({
|
||||
path = path.replace(/(https?\:)?\/\/[^\/]+/, "");
|
||||
|
||||
// Rewrite /my/* urls
|
||||
let myPath = getURL("/my");
|
||||
let myPath = getURL("/my/");
|
||||
const fullPath = getURL(path);
|
||||
if (fullPath.startsWith(myPath)) {
|
||||
const currentUser = User.current();
|
||||
if (currentUser) {
|
||||
path = fullPath.replace(
|
||||
myPath,
|
||||
userPath(currentUser.get("username_lower"))
|
||||
`${userPath(currentUser.get("username_lower"))}/`
|
||||
);
|
||||
} else {
|
||||
return this.redirectTo("/login-preferences");
|
||||
|
@ -90,6 +90,19 @@ module("Unit | Utility | url", function () {
|
||||
);
|
||||
});
|
||||
|
||||
test("routeTo does not rewrite routes started with /my", async function (assert) {
|
||||
logIn();
|
||||
sinon.stub(DiscourseURL, "router").get(() => {
|
||||
return { currentURL: "/" };
|
||||
});
|
||||
sinon.stub(DiscourseURL, "handleURL");
|
||||
DiscourseURL.routeTo("/myfeed");
|
||||
assert.ok(
|
||||
DiscourseURL.handleURL.calledWith(`/myfeed`),
|
||||
"it should navigate to the unmodified route"
|
||||
);
|
||||
});
|
||||
|
||||
test("prefixProtocol", async function (assert) {
|
||||
assert.strictEqual(
|
||||
prefixProtocol("mailto:mr-beaver@aol.com"),
|
||||
|
Loading…
Reference in New Issue
Block a user