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

Function resolveRelativeMarkdownPath

assets/article-cards.js:1023–1043  ·  view source on GitHub ↗
(href)

Source from the content-addressed store, hash-verified

1021 }
1022
1023 function resolveRelativeMarkdownPath(href) {
1024 var base = getCurrentRoute();
1025
1026 if (!base || base === 'README') {
1027 base = '';
1028 } else if (/\/README$/.test(base)) {
1029 base = base.replace(/README$/, '');
1030 } else {
1031 base = base.replace(/[^/]+$/, '');
1032 }
1033
1034 var rootPath = getSiteRootPath();
1035 var url = new URL(href, window.location.origin + rootPath + base);
1036 var path = url.pathname;
1037
1038 if (path.indexOf(rootPath) === 0) {
1039 path = path.slice(rootPath.length);
1040 }
1041
1042 return path.replace(/^\/+/, '');
1043 }
1044
1045 function resolveImageSource(src, markdownPath) {
1046 var trimmed = (src || '').trim();

Callers 1

toMarkdownPathFunction · 0.85

Calls 2

getCurrentRouteFunction · 0.85
getSiteRootPathFunction · 0.85

Tested by

no test coverage detected