glitch-javascript-sdk 1.4.7 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -202,35 +202,32 @@ class Requests {
202
202
  .join('&');
203
203
  url = `${url}?${queryString}`;
204
204
  }
205
-
205
+
206
206
  // Prepare FormData
207
207
  const formData = new FormData();
208
208
  formData.append(filename, blob);
209
-
209
+
210
210
  if (Requests.community_id) {
211
211
  data = {
212
212
  ...data,
213
213
  communities: [Requests.community_id],
214
214
  };
215
215
  }
216
-
216
+
217
217
  for (let key in data) {
218
218
  formData.append(key, data[key]);
219
219
  }
220
-
220
+
221
221
  // Prepare headers
222
- let headers: { [key: string]: string } = {
223
- 'Content-Type': 'multipart/form-data',
224
- };
225
-
222
+ let headers: { [key: string]: string } = {};
223
+
226
224
  if (Requests.authToken) {
227
225
  headers['Authorization'] = `Bearer ${Requests.authToken}`;
228
226
  }
229
-
230
- // Format URL
231
- url = url.replace(/\/\//g, '/');
232
- const uri = `${Requests.baseUrl}${url}`.replace(/\/\//g, '/');
233
-
227
+
228
+ // Format URL correctly
229
+ const uri = Requests.baseUrl.replace(/\/+$/, '') + '/' + url.replace(/^\/+/, '');
230
+
234
231
  // Make the request
235
232
  return axios({
236
233
  method: 'POST',
@@ -240,6 +237,7 @@ class Requests {
240
237
  onUploadProgress,
241
238
  });
242
239
  }
240
+
243
241
 
244
242
 
245
243
  // Method adapted for browser environments