blob: ad8582c2b667715b5fb4ad47d148210f2bfbfa16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
export default function (currentPath: string, relativePath: string) {
if (relativePath.length > 2 && relativePath.slice(0, 3) === '../') {
throw new Error('Cannot calculate relative path because it goes up a directory.');
}
if (currentPath.at(-1) !== '/') {
currentPath = currentPath + '/';
}
relativePath = relativePath.replace(/^\.?\//, '');
return currentPath + relativePath;
}
|