(src, markdownPath)
| 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; |
no test coverage detected