Skip to content

Commit 66e92c4

Browse files
committed
Lowercases name of Remote.ts & eliminates local copies of Dropbox URLs
1 parent 520e95a commit 66e92c4

File tree

9 files changed

+21
-31
lines changed

9 files changed

+21
-31
lines changed

doc/getting-started/dropbox-and-google-drive.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ An app key can be obtained by `registering your app
4545
* files.content.write
4646
* You need to set one or more OAuth2 redirect URIs for all routes a user can
4747
connect from, for example ``http://localhost:8000`` for an app you are
48-
developing locally. If the path is '/', remoteStorage drops it.
48+
developing locally. If the path is '/', rs.js drops it.
4949

5050
Known issues
5151
^^^^^^^^^^^^

src/authorize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import UnauthorizedError from './unauthorized-error';
55
import { EventHandler } from './interfaces/event_handling';
66
import {requestWithTimeout} from "./requests";
77
import {AuthorizeOptions} from "./interfaces/authorize_options";
8-
import {Remote} from "./Remote";
8+
import {Remote} from "./remote";
99

1010

1111
interface AuthResult {

src/dropbox.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
generateCodeVerifier,
1414
} from './util';
1515
import {requestWithTimeout, isArrayBufferView, retryAfterMs} from "./requests";
16-
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./Remote";
16+
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./remote";
1717
import RemoteStorage from "./remotestorage";
1818
import Authorize from "./authorize";
1919

@@ -282,7 +282,6 @@ class Dropbox extends RemoteBase implements Remote {
282282
* @private
283283
*/
284284
_getFolder (path: string) {
285-
const url = FOLDER_URL;
286285
const revCache = this._revCache;
287286

288287
const processResponse = (resp) => {
@@ -334,15 +333,14 @@ class Dropbox extends RemoteBase implements Remote {
334333
};
335334

336335
const loadNext = (cursor) => {
337-
const continueURL = CONTINUE_URL;
338336
const params = {
339337
body: { cursor: cursor }
340338
};
341339

342-
return this._request('POST', continueURL, params).then(processResponse);
340+
return this._request('POST', CONTINUE_URL, params).then(processResponse);
343341
};
344342

345-
return this._request('POST', url, {
343+
return this._request('POST', FOLDER_URL, {
346344
body: {
347345
path: getDropboxPath(path)
348346
}
@@ -371,8 +369,6 @@ class Dropbox extends RemoteBase implements Remote {
371369
*/
372370
get (path: string, options: { ifNoneMatch?: string } = {}): Promise<RemoteResponse> {
373371
if (! this.connected) { return Promise.reject("not connected (path: " + path + ")"); }
374-
const url = DOWNLOAD_URL;
375-
376372
const savedRev = this._revCache.get(path);
377373
if (savedRev === null) {
378374
// file was deleted server side
@@ -408,7 +404,7 @@ class Dropbox extends RemoteBase implements Remote {
408404
params.headers['If-None-Match'] = options.ifNoneMatch;
409405
}
410406

411-
return this._request('GET', url, params).then(resp => {
407+
return this._request('GET', DOWNLOAD_URL, params).then(resp => {
412408
const status = resp.status;
413409
let meta, body, mime, rev;
414410
if (status !== 200 && status !== 409) {
@@ -592,12 +588,11 @@ class Dropbox extends RemoteBase implements Remote {
592588
* @private
593589
*/
594590
share (path: string): Promise<string> {
595-
const url = CREATE_SHARED_URL;
596591
const options = {
597592
body: {path: getDropboxPath(path)}
598593
};
599594

600-
return this._request('POST', url, options).then((response) => {
595+
return this._request('POST', CREATE_SHARED_URL, options).then((response) => {
601596
if (response.status !== 200 && response.status !== 409) {
602597
return Promise.reject(new Error('Invalid response status:' + response.status));
603598
}
@@ -641,9 +636,7 @@ class Dropbox extends RemoteBase implements Remote {
641636
* @protected
642637
*/
643638
info (): Promise<{email: string}> {
644-
const url = ACCOUNT_URL;
645-
646-
return this._request('POST', url, {}).then(function (response) {
639+
return this._request('POST', ACCOUNT_URL, {}).then(function (response) {
647640
let email;
648641

649642
try {
@@ -768,13 +761,14 @@ class Dropbox extends RemoteBase implements Remote {
768761

769762
/** This should resolve (with no value) on success, and reject on error. */
770763
const fetch = async (cursor: string) => {
771-
let url = FOLDER_URL;
764+
let url;
772765
let requestBody;
773766

774767
if (typeof cursor === 'string') {
775-
url += '/continue';
768+
url = CONTINUE_URL;
776769
requestBody = { cursor };
777770
} else {
771+
url = FOLDER_URL;
778772
requestBody = {
779773
path: PATH_PREFIX,
780774
recursive: true,
@@ -873,12 +867,11 @@ class Dropbox extends RemoteBase implements Remote {
873867
* @private
874868
*/
875869
_getMetadata (path: string): Promise<Metadata> {
876-
const url = METADATA_URL;
877870
const requestBody = {
878871
path: getDropboxPath(path)
879872
};
880873

881-
return this._request('POST', url, { body: requestBody }).then((response) => {
874+
return this._request('POST', METADATA_URL, { body: requestBody }).then((response) => {
882875
if (response.status !== 200 && response.status !== 409) {
883876
return Promise.reject(new Error('Invalid response status:' + response.status));
884877
}
@@ -922,7 +915,6 @@ class Dropbox extends RemoteBase implements Remote {
922915
* @private
923916
*/
924917
_uploadSimple (params: { body: XMLHttpRequestBodyInit; contentType?: string; path: string; ifMatch?: string; }): Promise<RemoteResponse> {
925-
const url = UPLOAD_URL;
926918
const args = {
927919
path: getDropboxPath(params.path),
928920
mode: { '.tag': 'overwrite', update: undefined },
@@ -933,7 +925,7 @@ class Dropbox extends RemoteBase implements Remote {
933925
args.mode = { '.tag': 'update', update: params.ifMatch };
934926
}
935927

936-
return this._request('POST', url, {
928+
return this._request('POST', UPLOAD_URL, {
937929
body: params.body,
938930
headers: {
939931
'Content-Type': 'application/octet-stream',
@@ -982,10 +974,9 @@ class Dropbox extends RemoteBase implements Remote {
982974
* @private
983975
*/
984976
_deleteSimple (path: string): Promise<RemoteResponse> {
985-
const url = DELETE_URL;
986977
const requestBody = { path: getDropboxPath(path) };
987978

988-
return this._request('POST', url, { body: requestBody }).then((response) => {
979+
return this._request('POST', DELETE_URL, { body: requestBody }).then((response) => {
989980
if (response.status !== 200 && response.status !== 409) {
990981
return Promise.resolve({statusCode: response.status});
991982
}
@@ -1028,15 +1019,14 @@ class Dropbox extends RemoteBase implements Remote {
10281019
* @private
10291020
*/
10301021
async _getSharedLink (path: string): Promise<string> {
1031-
const url = LIST_SHARED_URL;
10321022
const options = {
10331023
body: {
10341024
path: getDropboxPath(path),
10351025
direct_only: true
10361026
}
10371027
};
10381028

1039-
return this._request('POST', url, options).then((response) => {
1029+
return this._request('POST', LIST_SHARED_URL, options).then((response) => {
10401030
if (response.status !== 200 && response.status !== 409) {
10411031
return Promise.reject(new Error('Invalid response status: ' + response.status));
10421032
}

src/googledrive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
localStorageAvailable
1111
} from './util';
1212
import {requestWithTimeout, RequestOptions} from "./requests";
13-
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./Remote";
13+
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./remote";
1414

1515
const BASE_URL = 'https://www.googleapis.com';
1616
const AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
File renamed without changes.

src/remotestorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Discover from './discover';
2525
import SyncError from './sync-error';
2626
import UnauthorizedError from './unauthorized-error';
2727
import Features from './features';
28-
import {Remote} from "./Remote";
28+
import {Remote} from "./remote";
2929

3030
// TODO this is assigned to RemoteStorage.util later; check if still needed
3131
import * as util from './util';

src/wireclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
shouldBeTreatedAsBinary
4646
} from './util';
4747
import {requestWithTimeout, isArrayBufferView} from "./requests";
48-
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./Remote";
48+
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./remote";
4949

5050
let hasLocalStorage;
5151
const SETTINGS_KEY = 'remotestorage:wireclient';

test/unit/authorize.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import fetchMock from 'fetch-mock';
88
import {localStorageAvailable} from "../../src/util";
99
import RemoteStorage from '../../src/remotestorage';
1010
import Authorize from '../../src/authorize';
11-
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "../../src/Remote";
11+
import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "../../src/remote";
1212

1313
chai.use(chaiAsPromised);
1414

test/unit/modules.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import 'mocha';
44
import { expect } from 'chai';
55
import RemoteStorage from '../../src/remotestorage';
6-
import {Remote} from "../../src/Remote";
7-
import {RemoteResponse, RemoteSettings} from "../../src/Remote";
6+
import {Remote} from "../../src/remote";
7+
import {RemoteResponse, RemoteSettings} from "../../src/remote";
88

99
describe('RemoteStorage module initialization', () => {
1010
const env = {

0 commit comments

Comments
 (0)