* Convert a relative path to absolute * * @param {String} href * @param {String} dir: directory parent of the file currently in rendering process * @param {String} outdir: directory parent from the html output * @return {String}
(_href, dir, outdir)
| 63 | * @return {String} |
| 64 | */ |
| 65 | function toAbsolute(_href, dir, outdir) { |
| 66 | if (isExternal(_href) || isDataURI(_href)) { |
| 67 | return _href; |
| 68 | } |
| 69 | |
| 70 | outdir = outdir == undefined? dir : outdir; |
| 71 | |
| 72 | _href = normalize(_href); |
| 73 | dir = normalize(dir); |
| 74 | outdir = normalize(outdir); |
| 75 | |
| 76 | // Path "_href" inside the base folder |
| 77 | var hrefInRoot = normalize(path.join(dir, _href)); |
| 78 | if (_href[0] == '/') { |
| 79 | hrefInRoot = normalize(_href.slice(1)); |
| 80 | } |
| 81 | |
| 82 | // Make it relative to output |
| 83 | _href = path.relative(outdir, hrefInRoot); |
| 84 | |
| 85 | // Normalize windows paths |
| 86 | _href = normalize(_href); |
| 87 | |
| 88 | return _href; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Convert an absolute path to a relative path for a specific folder (dir) |
nothing calls this directly
no test coverage detected
searching dependent graphs…