Fix URLs fully with relative path helper

This commit is contained in:
Justin Fagnani
2019-12-20 13:36:46 -08:00
committed by Justin Fagnani
parent 817f502dfa
commit 5ced993566
9 changed files with 55 additions and 41 deletions

View File

@@ -0,0 +1,9 @@
const path = require('path').posix;
module.exports = (base, p) => {
const relativePath = path.relative(base, p);
if (p.endsWith('/') && !relativePath.endsWith('/') && relativePath !== '') {
return relativePath + '/';
}
return relativePath;
};