MCPcopy Create free account
hub / github.com/crisxuan/bestJavaer / resolveImageSource

Function resolveImageSource

assets/article-cards.js:1045–1056  ·  view source on GitHub ↗
(src, markdownPath)

Source from the content-addressed store, hash-verified

1043 }
1044
1045 function resolveImageSource(src, markdownPath) {
1046 var trimmed = (src || '').trim();
1047
1048 if (/^(?:https?:)?\/\//i.test(trimmed) || /^(?:data|blob):/i.test(trimmed) || trimmed.charAt(0) === '/') {
1049 return trimmed;
1050 }
1051
1052 var rootPath = getSiteRootPath();
1053 var articleDirectory = markdownPath.replace(/[^/]+$/, '');
1054
1055 return new URL(trimmed, window.location.origin + rootPath + articleDirectory).href;
1056 }
1057
1058 function getSiteRootPath() {
1059 var path = window.location.pathname;

Callers 1

extractFirstImageFunction · 0.85

Calls 1

getSiteRootPathFunction · 0.85

Tested by

no test coverage detected