Skip to content

Commit 3c9038d

Browse files
committed
test for trailing slash in endpoint due to TUS error
1 parent acb5d49 commit 3c9038d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: src/Transloadit.js

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ class TransloaditClient {
7777
throw new Error('Please provide an authSecret')
7878
}
7979

80+
if (opts.endpoint && opts.endpoint.endsWith('/')) {
81+
throw new Error('Trailing slash in endpoint is not allowed')
82+
}
83+
8084
this._authKey = opts.authKey
8185
this._authSecret = opts.authSecret
8286
this._endpoint = opts.endpoint || 'https://api2.transloadit.com'

Diff for: test/unit/__tests__/test-transloadit-client.js

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ describe('Transloadit', () => {
3535
expect(client._defaultTimeout).toBe(10000)
3636
})
3737

38+
it('should throw when sending a trailing slash in endpoint', () => {
39+
const opts = {
40+
authKey : 'foo_key',
41+
authSecret: 'foo_secret',
42+
endpoint : 'https://api2.transloadit.com/',
43+
}
44+
expect(() => new Transloadit(opts)).toThrow('Trailing slash in endpoint is not allowed')
45+
})
46+
3847
it('should give error when no authSecret', () => {
3948
expect(() => new Transloadit({ authSecret: '' })).toThrow()
4049
})

0 commit comments

Comments
 (0)