MCPcopy
hub / github.com/mitmproxy/mitmproxy / updateUrlFromStore

Function updateUrlFromStore

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

Source from the content-addressed store, hash-verified

70}
71
72export function updateUrlFromStore(store: RootStore) {
73 const state = store.getState();
74 const query = {
75 [Query.SEARCH]: state.ui.filter[FilterName.Search],
76 [Query.HIGHLIGHT]: state.ui.filter[FilterName.Highlight],
77 [Query.SHOW_EVENTLOG]: state.eventLog.visible,
78 [Query.SHOW_COMMANDBAR]: state.commandBar.visible,
79 };
80 const queryStr = Object.keys(query)
81 .filter((k) => query[k])
82 .map((k) => `${k}=${encodeURIComponent(query[k]!)}`)
83 .join("&");
84
85 let url;
86 if (state.ui.tabs.current === Tab.Capture) {
87 url = "/capture";
88 } else if (state.flows.selected.length > 0) {
89 url = `/flows/${state.flows.selected[0].id}/${state.ui.flow.tab}`;
90 } else {
91 url = "/flows";
92 }
93
94 if (queryStr) {
95 url += "?" + queryStr;
96 }
97 let pathname = window.location.pathname;
98 if (pathname === "blank") {
99 pathname = "/"; // this happens in tests...
100 }
101 if (window.location.hash.substr(1) !== url) {
102 history.replaceState(undefined, "", `${pathname}#${url}`);
103 }
104}
105
106export default function initialize(store) {
107 updateStoreFromUrl(store);

Callers 2

urlStateSpec.tsxFile · 0.90
initializeFunction · 0.85

Calls 4

joinMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…