rename files

This commit is contained in:
2021-09-02 19:52:34 +02:00
parent cd20f098fa
commit 96e435a976
2 changed files with 20 additions and 4 deletions

View 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