MCPcopy Create free account
hub / github.com/danmactough/node-feedparser / resolveSrcset

Function resolveSrcset

lib/utils.js:85–105  ·  view source on GitHub ↗
(baseUrl, srcset)

Source from the content-addressed store, hash-verified

83}
84
85function resolveSrcset (baseUrl, srcset) {
86 if (!baseUrl || !srcset || typeof srcset !== 'string') return srcset;
87
88 var out = '';
89 var start = 0;
90 var depth = 0;
91 var i;
92 for (i = 0; i < srcset.length; i++) {
93 if (srcset[i] === '(') {
94 depth++;
95 } else if (srcset[i] === ')' && depth) {
96 depth--;
97 } else if (srcset[i] === ',' && depth === 0) {
98 // Do not split commas that are part of functional URL notation.
99 out += resolveSrcsetCandidate(baseUrl, srcset.slice(start, i)) + ',';
100 start = i + 1;
101 }
102 }
103
104 return out + resolveSrcsetCandidate(baseUrl, srcset.slice(start));
105}
106
107function resolveHtmlAttributeValue (baseUrl, name, value) {
108 var attrName = name.toLowerCase();

Callers 1

Calls 1

resolveSrcsetCandidateFunction · 0.85

Tested by

no test coverage detected