Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(web): return real navigation state from history.location getter (#17324)

Try everything4457764e11d0
diff --git a/web/src/utils/__tests__/simple-history-util.test.ts b/web/src/utils/__tests__/simple-history-util.test.ts
new file mode 100644
index 0000000000..87e4548ee2
--- /dev/null
+++ b/web/src/utils/__tests__/simple-history-util.test.ts
@@ -0,0 +1,34 @@
+import { history } from '../simple-history-util';
+
+describe('simple-history-util history.location', () => {
+ afterEach(() => {
+ window.history.replaceState(null, '', '/');
+ });
+
+ it('exposes the current path segments from window.location', () => {
+ window.history.replaceState(null, '', '/foo?bar=1#baz');
+
+ expect(history.location.pathname).toBe('/foo');
+ expect(history.location.search).toBe('?bar=1');
+ expect(history.location.hash).toBe('#baz');
+ });
+
+ it('reflects the real browser navigation state after replace()', () => {
+ const state = { token: 'abc' };
+ history.replace('/session', state);
+
+ expect(window.history.state).toEqual(state);
+ // Regression: the getter previously read the GlobalHistory instance's
+ // own (never-assigned) `state` field instead of window.history.state,
+ // so it always returned undefined.
+ expect(history.location.state).toEqual(state);
+ });
+
+ it('reflects the real browser navigation state after push()', () => {
+ const state = { from: '/prev' };
+ history.push('/next', state);
+
+ expect(history.location.state).toEqual(state);
+ expect(history.location.state).toEqual(window.history.state);
+ });
+});
diff --git a/web/src/utils/simple-history-util.ts b/web/src/utils/simple-history-util.ts
index dfd2489d0f..a59af05396 100644
--- a/web/src/utils/simple-history-util.ts
+++ b/web/src/utils/simple-history-util.ts
@@ -121,7 +121,7 @@ class GlobalHistory {
pathname: window.location.pathname,
search: window.location.search,
hash: window.location.hash,
- state: history.state,
+ state: window.history.state,
};
}