MCPcopy
hub / github.com/mitmproxy/mitmproxy / updateStoreFromUrl

Function updateStoreFromUrl

web/src/js/urlState.ts:23–70  ·  view source on GitHub ↗
(store: RootStore)

Source from the content-addressed store, hash-verified

21};
22
23export function updateStoreFromUrl(store: RootStore) {
24 const [path, query] = window.location.hash.substr(1).split("?", 2);
25 const path_components = path.substr(1).split("/");
26
27 if (path_components[0] === "flows") {
28 if (path_components.length == 3) {
29 const [flowId, tab] = path_components.slice(1);
30 store.dispatch(selectTab(tab));
31
32 const selectFlowOnceAvailable = () => {
33 const flow = store.getState().flows.byId.get(flowId);
34 if (flow !== undefined) {
35 unsubscribe();
36 store.dispatch(select([flow]));
37 }
38 };
39 const unsubscribe = store.subscribe(selectFlowOnceAvailable);
40 selectFlowOnceAvailable();
41 }
42 } else if (path_components[0] === "capture") {
43 store.dispatch(setCurrent(Tab.Capture));
44 }
45
46 if (query) {
47 query.split("&").forEach((x) => {
48 const [key, encodedVal] = x.split("=", 2);
49 const value = decodeURIComponent(encodedVal);
50 switch (key) {
51 case Query.SEARCH:
52 store.dispatch(setFilter(value));
53 break;
54 case Query.HIGHLIGHT:
55 store.dispatch(setHighlight(value));
56 break;
57 case Query.SHOW_EVENTLOG:
58 if (!store.getState().eventLog.visible)
59 store.dispatch(eventLogActions.toggleVisibility());
60 break;
61 case Query.SHOW_COMMANDBAR:
62 if (!store.getState().commandBar.visible)
63 store.dispatch(commandBarActions.toggleVisibility());
64 break;
65 default:
66 console.error(`unimplemented query arg: ${x}`);
67 }
68 });
69 }
70}
71
72export function updateUrlFromStore(store: RootStore) {
73 const state = store.getState();

Callers 2

urlStateSpec.tsxFile · 0.90
initializeFunction · 0.85

Calls 10

selectTabFunction · 0.90
setCurrentFunction · 0.90
setFilterFunction · 0.90
setHighlightFunction · 0.90
selectFlowOnceAvailableFunction · 0.85
dispatchMethod · 0.80
subscribeMethod · 0.80
splitMethod · 0.45
sliceMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…