MCPcopy Create free account
hub / github.com/microsoft/SandDance / getResourceUrlAndType

Function getResourceUrlAndType

docs/app/js/sanddance-app.js:55336–55357  ·  view source on GitHub ↗
(resource)

Source from the content-addressed store, hash-verified

55334var _mimeTypeUtils = require("./mime-type-utils");
55335var QUERY_STRING_PATTERN = /\?.*/;
55336function getResourceUrlAndType(resource) {
55337 if ((0, _isType.isResponse)(resource)) {
55338 var contentType = (0, _mimeTypeUtils.parseMIMEType)(resource.headers.get("content-type"));
55339 var urlType = (0, _mimeTypeUtils.parseMIMETypeFromURL)(resource.url);
55340 return {
55341 url: stripQueryString(resource.url || ""),
55342 type: contentType || urlType || null
55343 };
55344 }
55345 if ((0, _isType.isBlob)(resource)) return {
55346 url: stripQueryString(resource.name || ""),
55347 type: resource.type || ""
55348 };
55349 if (typeof resource === "string") return {
55350 url: stripQueryString(resource),
55351 type: (0, _mimeTypeUtils.parseMIMETypeFromURL)(resource)
55352 };
55353 return {
55354 url: "",
55355 type: ""
55356 };
55357}
55358function getResourceContentLength(resource) {
55359 if ((0, _isType.isResponse)(resource)) return resource.headers["content-length"] || -1;
55360 if ((0, _isType.isBlob)(resource)) return resource.size;

Callers

nothing calls this directly

Calls 2

stripQueryStringFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected