code: function getPathToRoot(filePath) {
  	filePath = filePath.replace(/\\/g, "/");
  
  	var lastSlash = filePath.lastIndexOf("/");
  	// strip out file name from the path
  	filePath = lastSlash >= 0 ? filePath.slice(0, lastSlash + 1) : "";
  
  	if (!filePath) {
  		return "";
  	}
      // now "folder1/folder2/file.ext" became "folder1/folder2/"
  	filePath = filePath.replace(/[^/]+/g, "..");
  	if (filePath.charAt(0) === "/") {
  		filePath = filePath.slice(1);
  	}
  	return filePath;
  }
docs: Makes from a filepath ("folder1/folder2/file.ext") a folder path to the root ("../../")