]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Remove the eventual trailing '/' at the end of urls (see #1453) (#1480)
authorHesioZ <HesioZ.Gamer@gmail.com>
Sat, 15 Dec 2018 00:43:04 +0000 (01:43 +0100)
committerRigel Kent <par@rigelk.eu>
Sat, 15 Dec 2018 00:43:04 +0000 (01:43 +0100)
remove eventual trailing '/' at the end of urls in import script (see #1453)

server/tools/peertube-import-videos.ts

index 1fe0a93488a08c43c66571294283fa5e1de9a378..2874a213197944ac1629c8f89f8e58167784b3cc 100644 (file)
@@ -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)
+  }
+}