rename files
This commit is contained in:
11
src/functions/pathRename.ts
Normal file
11
src/functions/pathRename.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
function pathRename(id:string, newFilename: string): string {
|
||||
const isDir = id.endsWith("/")
|
||||
const parts = id.split("/")
|
||||
if (!parts.length)
|
||||
throw new Error("Maleformed id")
|
||||
parts[parts.length - (isDir?2:1)] = newFilename
|
||||
|
||||
return parts.join("/")
|
||||
}
|
||||
|
||||
export default pathRename
|
||||
Reference in New Issue
Block a user