mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 20:23:32 +08:00
maintain (eslint): linting on frontend
This commit is contained in:
@ -1,21 +1,21 @@
|
||||
import Path from 'path';
|
||||
import Path from "path";
|
||||
|
||||
export function pathBuilder(path, filename, type = 'file'){
|
||||
let tmp = Path.resolve(path, filename)
|
||||
if(type === 'file'){
|
||||
export function pathBuilder(path, filename, type = "file") {
|
||||
const tmp = Path.resolve(path, filename);
|
||||
if (type === "file") {
|
||||
return tmp;
|
||||
}else{
|
||||
return tmp + '/';
|
||||
} else {
|
||||
return tmp + "/";
|
||||
}
|
||||
}
|
||||
|
||||
export function basename(path){
|
||||
export function basename(path) {
|
||||
return Path.basename(path);
|
||||
}
|
||||
|
||||
export function dirname(path){
|
||||
export function dirname(path) {
|
||||
const dir = Path.dirname(path);
|
||||
if(dir === '/') return dir;
|
||||
if (dir === "/") return dir;
|
||||
return dir + "/";
|
||||
}
|
||||
|
||||
@ -23,35 +23,35 @@ export function filetype(path) {
|
||||
return path.slice(-1) === "/" ? "directory" : "file";
|
||||
}
|
||||
|
||||
export function absoluteToRelative(from, to){
|
||||
export function absoluteToRelative(from, to) {
|
||||
// remove any trace of file that would be interpreted by the path lib as a folder
|
||||
from = from.replace(/\/[^\/]+$/, "/");
|
||||
let r = Path.relative(from, to);
|
||||
if(r.substring(0,3) !== "../"){
|
||||
r = "./"+r
|
||||
if (r.substring(0, 3) !== "../") {
|
||||
r = "./" + r;
|
||||
}
|
||||
if(/\/$/.test(to) === true && r !== "./"){
|
||||
r += "/"
|
||||
if (/\/$/.test(to) === true && r !== "./") {
|
||||
r += "/";
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
export function currentShare(){
|
||||
export function currentShare() {
|
||||
return findParams("share");
|
||||
}
|
||||
|
||||
export function findParams(p){
|
||||
return new window.URL(location.href).searchParams.get(p) || ""
|
||||
export function findParams(p) {
|
||||
return new window.URL(location.href).searchParams.get(p) || "";
|
||||
}
|
||||
|
||||
export function appendShareToUrl(link) {
|
||||
let url = new window.URL(location.href);
|
||||
let share = url.searchParams.get("share");
|
||||
const share = url.searchParams.get("share");
|
||||
|
||||
if(share){
|
||||
url = new window.URL(location.origin + link)
|
||||
url.searchParams.set("share", share)
|
||||
return url.pathname + url.search
|
||||
if (share) {
|
||||
url = new window.URL(location.origin + link);
|
||||
url.searchParams.set("share", share);
|
||||
return url.pathname + url.search;
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user