Use UTF-8 safe return-to encoding and decoding across router and login
Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/06
|
||||
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { decodeReturnTo } from "@/utils/returnToEncoding";
|
||||
|
||||
describe("router beforeEach guard logic", () => {
|
||||
beforeEach(() => {
|
||||
@@ -70,7 +71,7 @@ describe("router beforeEach guard logic", () => {
|
||||
matched: [{ meta: { requiresAuth: true } }],
|
||||
});
|
||||
expect(result.path).toBe("/login");
|
||||
expect(atob(result.query["return-to"])).toBe("/files");
|
||||
expect(decodeReturnTo(result.query["return-to"])).toBe("/files");
|
||||
});
|
||||
|
||||
it("allows requiresAuth route when refresh token can refresh session", () => {
|
||||
@@ -100,7 +101,7 @@ describe("router beforeEach guard logic", () => {
|
||||
{ refreshSucceeds: false },
|
||||
);
|
||||
expect(result.path).toBe("/login");
|
||||
expect(atob(result.query["return-to"])).toBe(
|
||||
expect(decodeReturnTo(result.query["return-to"])).toBe(
|
||||
"/discover/log/1/map?view=summary#node-2",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user