MCPcopy
hub / github.com/webpack/webpack / parseKeyValuePairs

Function parseKeyValuePairs

lib/schemes/HttpUriPlugin.js:147–163  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

145 * @returns {Record<string, string>} parsed
146 */
147const parseKeyValuePairs = (str) => {
148 /** @type {Record<string, string>} */
149 const result = {};
150 for (const item of str.split(",")) {
151 const i = item.indexOf("=");
152 if (i >= 0) {
153 const key = item.slice(0, i).trim();
154 const value = item.slice(i + 1).trim();
155 result[key] = value;
156 } else {
157 const key = item.trim();
158 if (!key) continue;
159 result[key] = key;
160 }
161 }
162 return result;
163};
164
165/**
166 * Parses cache control.

Callers 1

parseCacheControlFunction · 0.85

Calls 2

splitMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected