Skip to content

Commit 41bced5

Browse files
committed
fix(pkg/backupServer/WebDAV): replace path normalization with url-join for consistency
1 parent 61183c9 commit 41bced5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/packages/backupServer/entity/WebDAV.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import urlJoin from "url-join";
12
import { AuthType, createClient, type FileStat, type WebDAVClient } from "webdav";
23

34
import AbstractBackupServer from "../AbstractBackupServer.ts";
@@ -45,11 +46,6 @@ export default class WebDAV extends AbstractBackupServer<WebDAVConfig> {
4546
return this.server;
4647
}
4748

48-
private normalizeRemotePath(path: string): string {
49-
// Keep exactly one leading slash so '/foo.zip' and 'foo.zip' behave consistently.
50-
return `/${path}`.replace(/^\/+/, "/");
51-
}
52-
5349
async ping(): Promise<boolean> {
5450
try {
5551
await this.getServer().getDirectoryContents("/");
@@ -84,14 +80,14 @@ export default class WebDAV extends AbstractBackupServer<WebDAVConfig> {
8480
}
8581

8682
async getFile(path: string): Promise<IBackupData> {
87-
const fileBuffer = await this.getServer().getFileContents(this.normalizeRemotePath(path));
83+
const fileBuffer = await this.getServer().getFileContents(urlJoin("/", path));
8884
const data = new Blob([fileBuffer as ArrayBuffer]);
8985

9086
return await this.jsZipBlobToBackupData(data);
9187
}
9288

9389
async deleteFile(path: string): Promise<boolean> {
94-
await this.getServer().deleteFile(this.normalizeRemotePath(path));
90+
await this.getServer().deleteFile(urlJoin("/", path));
9591
return true;
9692
}
9793
}

src/packages/site/utils/datetime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export const dateUnit: Array<DurationUnit | "quarters"> = [
2828
export const nonStandDateUnitMap: Record<(typeof dateUnit)[number], string[]> = {
2929
years: ["年", "year", "yr", "Y"],
3030
quarters: ["季度", "quarter", "qtr"],
31-
months: ["月", "month", "mo", "M"],
31+
months: ["個月", "月", "month", "mo", "M"],
3232
weeks: ["周", "week", "wk", "W"],
3333
days: ["天", "day", "D"],
34-
hours: ["时", "hour", "hr", "h"],
35-
minutes: ["分", "minute", "min", "m"],
34+
hours: ["小時", "时", "hour", "hr", "h"],
35+
minutes: ["分鐘", "分", "minute", "min", "m"],
3636
seconds: ["秒", "second", "sec", "s"],
3737
};
3838

0 commit comments

Comments
 (0)