1 | 1 | var path = require('path'); |
|
2 | 1 | var slash = require('slash'); |
|
3 | |||
4 | function processRoot (page, root) { |
||
5 | 100 | var pagePath = path.dirname(page); |
|
6 | 100 | var rootPath = path.join(process.cwd(), root); |
|
7 | 100 | var relativePath = path.relative(pagePath, rootPath); |
|
8 | |||
9 | 100 | if (relativePath.length == 0) { |
|
0 ignored issues
–
show
Best Practice
introduced
by
Loading history...
|
|||
10 | 23 | relativePath = '.'; |
|
11 | } |
||
12 | 100 | if (relativePath.length > 0) { |
|
13 | 100 | relativePath += '/'; |
|
14 | } |
||
15 | |||
16 | // On Windows, paths are separated with a "\" |
||
17 | // However, web browsers use "/" no matter the platform : slash(...) |
||
18 | 100 | return slash(relativePath); |
|
19 | } |
||
20 | |||
21 | |||
22 | module.exports = processRoot; |