MCPcopy
hub / github.com/GitbookIO/gitbook / relative

Function relative

lib/utils/location.js:99–102  ·  view source on GitHub ↗

* Convert an absolute path to a relative path for a specific folder (dir) * ('test/', 'hello.md') -> '../hello.md' * * @param {String} dir: current directory * @param {String} file: absolute path of file * @return {String}

(dir, file)

Source from the content-addressed store, hash-verified

97 * @return {String}
98 */
99function relative(dir, file) {
100 var isDirectory = file.slice(-1) === '/';
101 return normalize(path.relative(dir, file)) + (isDirectory? '/': '');
102}
103
104/**
105 * Convert an absolute path to a relative path for a specific folder (dir)

Callers 1

relativeForFileFunction · 0.85

Calls 1

normalizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…