Skip to content

Commit af65f13

Browse files
committed
Adding a colon if necessary in purge command
Uniformized the appending of a colon after the fs accross functions Adding a missing return after an early reject and two semicolons Correcting a typo, `fs` to `remoteName`
1 parent dc36840 commit af65f13

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/index.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export const setCurrentBandwidthSetting = (newRate) => {
5656
* @returns {Function}
5757
*/
5858
export const createNewPublicLink = (remoteName, remotePath) => {
59-
remoteName = tools.addColonAtLast(remoteName);
59+
if (!isLocalRemoteName(remoteName)) {
60+
fs = addColonAtLast(remoteName);
61+
}
6062
return new Promise((resolve, reject) => {
6163
axiosInstance.post(urls.createPublicLink, {fs: remoteName, remote: remotePath}).then(res => {
6264
resolve(res.data);
@@ -123,11 +125,13 @@ export const getFsInfo = (remoteName) => {
123125
export const getFilesList = (fs, remotePath) => {
124126
return new Promise((resolve, reject) => {
125127
if(!fs || fs === ""){
126-
reject("Invalid fs specified")
128+
reject("Invalid fs specified");
129+
return;
127130
}
128131

129-
// check if it is a local path
130-
fs = fs.indexOf('/') !== 0 ? addColonAtLast(fs) : fs;
132+
if (!isLocalRemoteName(fs)) {
133+
fs = addColonAtLast(fs);
134+
}
131135

132136
axiosInstance.post(urls.getFilesList, {
133137
fs,
@@ -150,8 +154,8 @@ export const getRemoteInfo = (remoteName) => {
150154
return new Promise((resolve, reject) => {
151155

152156
if(!remoteName) {
153-
reject("Invalid remote name specified")
154-
return
157+
reject("Invalid remote name specified");
158+
return;
155159
}
156160

157161
if (!isLocalRemoteName(remoteName)) {
@@ -219,6 +223,9 @@ export const getJobStatus = (jobId) => {
219223
* @return {Promise<unknown>}
220224
*/
221225
export const purgeDir = (fs , remote) => {
226+
if (!isLocalRemoteName(fs)) {
227+
fs = addColonAtLast(fs);
228+
}
222229
return new Promise((resolve, reject) => {
223230
axiosInstance.post(urls.purge, {
224231
fs,
@@ -239,7 +246,9 @@ export const purgeDir = (fs , remote) => {
239246
* @return {Promise<unknown>}
240247
*/
241248
export const deleteFile = (fs , remote) => {
242-
fs = addColonAtLast(fs)
249+
if (!isLocalRemoteName(fs)) {
250+
fs = addColonAtLast(fs);
251+
}
243252
return new Promise((resolve, reject) => {
244253
axiosInstance.post(urls.deleteFile, {
245254
fs,

0 commit comments

Comments
 (0)