diff options
Diffstat (limited to 'server/tools/peertube-auth.ts')
-rw-r--r-- | server/tools/peertube-auth.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts index 1a4fae4ce..6a0b89fe2 100644 --- a/server/tools/peertube-auth.ts +++ b/server/tools/peertube-auth.ts | |||
@@ -46,6 +46,15 @@ function isURLaPeerTubeInstance (url: string) { | |||
46 | return url.startsWith('http://') || url.startsWith('https://') | 46 | return url.startsWith('http://') || url.startsWith('https://') |
47 | } | 47 | } |
48 | 48 | ||
49 | function stripExtraneousFromPeerTubeUrl (url: string) { | ||
50 | // Get everything before the 3rd /. | ||
51 | const urlLength = url.includes('/', 8) | ||
52 | ? url.indexOf('/', 8) | ||
53 | : url.length | ||
54 | |||
55 | return url.substr(0, urlLength) | ||
56 | } | ||
57 | |||
49 | program | 58 | program |
50 | .name('auth') | 59 | .name('auth') |
51 | .usage('[command] [options]') | 60 | .usage('[command] [options]') |
@@ -80,8 +89,13 @@ program | |||
80 | } | 89 | } |
81 | } | 90 | } |
82 | }, async (_, result) => { | 91 | }, async (_, result) => { |
92 | |||
83 | // Check credentials | 93 | // Check credentials |
84 | try { | 94 | try { |
95 | // Strip out everything after the domain:port. | ||
96 | // @see https://github.com/Chocobozzz/PeerTube/issues/3520 | ||
97 | result.url = stripExtraneousFromPeerTubeUrl(result.url) | ||
98 | |||
85 | await getAccessToken(result.url, result.username, result.password) | 99 | await getAccessToken(result.url, result.username, result.password) |
86 | } catch (err) { | 100 | } catch (err) { |
87 | console.error(err.message) | 101 | console.error(err.message) |