export function relativeToAbsolute(base: string, relative: string) {
	const stack = base.split('/');
	const parts = relative.split('/');
	stack.pop();
	for (let i = 0; i < parts.length; i++) {
		if (parts[i] === '.') continue;
		if (parts[i] === '..') stack.pop();
		if (parts[i] === stack[i]) continue;
		else stack.push(parts[i]);
	}
	return stack.join('/');
}

export function removeFileExtension(file: string) {
	return file.replace(/\.[^/.]+$/, '');
}

export function renameFile(originalFile: File, newName: string) {
	return new File([originalFile], newName, {
		type: originalFile.type,
		lastModified: originalFile.lastModified
	});
}
