MCPcopy Index your code
hub / github.com/hoothin/UserScripts / getHeaderValue

Function getHeaderValue

Pagetual/pagetual.user.js:4173–4187  ·  view source on GitHub ↗
(headers, name)

Source from the content-addressed store, hash-verified

4171
4172 function requestWithFetch(f, onFetchError) {
4173 function getHeaderValue(headers, name) {
4174 if (!headers || !name) return "";
4175 let lowerName = String(name).toLowerCase();
4176 if (typeof Headers !== "undefined" && headers instanceof Headers) {
4177 return headers.get(lowerName) || "";
4178 }
4179 if (typeof headers === "object") {
4180 for (let key in headers) {
4181 if (Object.prototype.hasOwnProperty.call(headers, key) && String(key).toLowerCase() === lowerName) {
4182 return headers[key] || "";
4183 }
4184 }
4185 }
4186 return "";
4187 }
4188 function extractCharsetFromContentType(contentType) {
4189 if (!contentType || typeof contentType !== "string") return "";
4190 let match = contentType.match(/charset\s*=\s*["']?([^;"'\s]+)/i);

Callers 1

requestWithFetchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected