MCPcopy Create free account
hub / github.com/coder/coder / parseFilterQuery

Function parseFilterQuery

site/src/components/Filter/Filter.tsx:105–122  ·  view source on GitHub ↗
(filterQuery: string)

Source from the content-addressed store, hash-verified

103};
104
105const parseFilterQuery = (filterQuery: string): FilterValues => {
106 if (filterQuery === "") {
107 return {};
108 }
109
110 const result: FilterValues = {};
111 const keyValuePair = /(\w+):"([^"]+)"|(\w+):(\S+)/g;
112
113 for (const match of filterQuery.matchAll(keyValuePair)) {
114 const key = match[1] ?? match[3];
115 const value = match[2] ?? match[4];
116 if (key && value) {
117 result[key] = value;
118 }
119 }
120
121 return result;
122};
123
124const stringifyFilter = (filterValue: FilterValues): string => {
125 let result = "";

Callers 1

useFilterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected