Skip to content

Commit

Permalink
test for trailing slash in endpoint due to TUS error
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Feb 8, 2021
1 parent acb5d49 commit 3c9038d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Transloadit.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class TransloaditClient {
throw new Error('Please provide an authSecret')
}

if (opts.endpoint && opts.endpoint.endsWith('/')) {
throw new Error('Trailing slash in endpoint is not allowed')
}

this._authKey = opts.authKey
this._authSecret = opts.authSecret
this._endpoint = opts.endpoint || 'https://api2.transloadit.com'
Expand Down
9 changes: 9 additions & 0 deletions test/unit/__tests__/test-transloadit-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ describe('Transloadit', () => {
expect(client._defaultTimeout).toBe(10000)
})

it('should throw when sending a trailing slash in endpoint', () => {
const opts = {
authKey : 'foo_key',
authSecret: 'foo_secret',
endpoint : 'https://api2.transloadit.com/',
}
expect(() => new Transloadit(opts)).toThrow('Trailing slash in endpoint is not allowed')
})

it('should give error when no authSecret', () => {
expect(() => new Transloadit({ authSecret: '' })).toThrow()
})
Expand Down

0 comments on commit 3c9038d

Please sign in to comment.