Skip to content

Commit

Permalink
Fix baseApiUrl (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtruong-dbx authored Nov 3, 2021
1 parent 86092fb commit 0fd7f5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dropbox",
"version": "10.15.0",
"version": "10.16.0",
"registry": "npm",
"description": "The Dropbox JavaScript SDK is a lightweight, promise based interface to the Dropbox v2 API that works in both nodejs and browser environments.",
"main": "cjs/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ function getSafeUnicode(c) {
}

export const baseApiUrl = (subdomain, domain = DEFAULT_API_DOMAIN, domainDelimiter = '.') => {
if (!domainDelimiter) {
return `https://${domain}/2/`;
}
if (domain !== DEFAULT_API_DOMAIN && TEST_DOMAIN_MAPPINGS[subdomain] !== undefined) {
subdomain = TEST_DOMAIN_MAPPINGS[subdomain];
domainDelimiter = '-';
Expand Down
7 changes: 7 additions & 0 deletions test/unit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import {

describe('Dropbox utils', () => {
describe('baseApiUrl', () => {
it('correctly sets base url when domainDelimiter is empty', () => {
const host = 'api';
const domain = 'mydomain.com';
const testUrl = baseApiUrl(host, domain, '');
chai.assert.equal(testUrl, 'https://mydomain.com/2/');
});

it('correctly sets base url when provided a subdomain', () => {
const host = 'test';
const testUrl = baseApiUrl(host);
Expand Down

0 comments on commit 0fd7f5d

Please sign in to comment.