Sha256: 11911058b38a5a7f935edefd59b2ce4516d9f8d2bb22188e1723d65c7baae0d7

Contents?: true

Size: 404 Bytes

Versions: 3

Compression:

Stored size: 404 Bytes

Contents

export default function getRelativePath ( from, to ) {
	const fromParts = from.split( /[\/\\]/ );
	const toParts = to.split( /[\/\\]/ );

	fromParts.pop(); // get dirname

	while ( fromParts[0] === toParts[0] ) {
		fromParts.shift();
		toParts.shift();
	}

	if ( fromParts.length ) {
		let i = fromParts.length;
		while ( i-- ) fromParts[i] = '..';
	}

	return fromParts.concat( toParts ).join( '/' );
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jass-vue-0.4.0 vendor/node_modules/magic-string/src/utils/getRelativePath.js
jass-vue-0.3.0 vendor/node_modules/magic-string/src/utils/getRelativePath.js
jass-vue-0.2.1 vendor/node_modules/magic-string/src/utils/getRelativePath.js