From: HesioZ Date: Sat, 15 Dec 2018 00:43:04 +0000 (+0100) Subject: Remove the eventual trailing '/' at the end of urls (see #1453) (#1480) X-Git-Tag: v1.2.0-rc.1~69 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=ab4dbe36579f6d92511e78cae2762c49a97001fe;p=github%2FChocobozzz%2FPeerTube.git Remove the eventual trailing '/' at the end of urls (see #1453) (#1480) remove eventual trailing '/' at the end of urls in import script (see #1453) --- diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 1fe0a9348..2874a2131 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -58,6 +58,7 @@ getSettings() settings.remotes[settings.default] : settings.remotes[0] } + if (!program['username']) program['username'] = netrc.machines[program['url']].login if (!program['password']) program['password'] = netrc.machines[program['url']].password } @@ -69,6 +70,9 @@ getSettings() process.exit(-1) } + removeEndSlashes(program['url']) + removeEndSlashes(program['targetUrl']) + const user = { username: program['username'], password: program['password'] @@ -321,3 +325,9 @@ function isNSFW (info: any) { return false } + +function removeEndSlashes (url: string) { + while (url.endsWith('/')) { + url.slice(0, -1) + } +}