Skip to content

Commit cedf6fb

Browse files
committed
Fix endpoint
1 parent 59c565d commit cedf6fb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/common/backup/web-dav/coordinator.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ import DateIterator from "@util/date-iterator"
33
import { processDir } from "../common"
44
import { CLIENT_FILE_NAME, convertClients2Markdown, divideByDate, parseData } from "../markdown"
55

6+
function getEndpoint(ext: timer.backup.TypeExt): string {
7+
let { endpoint } = ext || {}
8+
if (endpoint?.endsWith('/')) {
9+
endpoint = endpoint.substring(0, endpoint.length - 1)
10+
}
11+
return endpoint
12+
}
13+
614
function prepareContext(context: timer.backup.CoordinatorContext<never>): WebDAVContext {
715
const { auth, ext } = context
8-
let { endpoint } = ext || {}
16+
const endpoint = getEndpoint(ext)
917
const webDavAuth: WebDAVAuth = {
1018
type: "password",
1119
username: auth?.login?.acc,
@@ -78,10 +86,11 @@ export default class WebDAVCoordinator implements timer.backup.Coordinator<never
7886
}
7987

8088
async testAuth(auth: timer.backup.Auth, ext: timer.backup.TypeExt): Promise<string> {
81-
const { endpoint, dirPath } = ext || {}
89+
const endpoint = getEndpoint(ext)
8290
if (!endpoint) {
8391
return "The endpoint is blank"
8492
}
93+
const { dirPath } = ext || {}
8594
if (!dirPath) {
8695
return "The path of directory is blank"
8796
}

0 commit comments

Comments
 (0)