files.com 1.0.419 → 1.0.421
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/_VERSION +1 -1
- package/lib/Api.js +2 -2
- package/lib/Files.js +1 -1
- package/lib/models/AccountLineItem.js +2 -2
- package/lib/models/Action.js +2 -2
- package/lib/models/ActionNotificationExport.js +2 -2
- package/lib/models/ActionNotificationExportResult.js +2 -2
- package/lib/models/ActionWebhookFailure.js +2 -2
- package/lib/models/ApiKey.js +2 -2
- package/lib/models/App.js +2 -2
- package/lib/models/As2IncomingMessage.js +2 -2
- package/lib/models/As2OutgoingMessage.js +2 -2
- package/lib/models/As2Partner.js +2 -2
- package/lib/models/As2Station.js +2 -2
- package/lib/models/Auto.js +2 -2
- package/lib/models/Automation.js +2 -2
- package/lib/models/AutomationRun.js +2 -2
- package/lib/models/BandwidthSnapshot.js +2 -2
- package/lib/models/Behavior.js +2 -2
- package/lib/models/Bundle.js +2 -2
- package/lib/models/BundleDownload.js +2 -2
- package/lib/models/BundleNotification.js +2 -2
- package/lib/models/BundleRecipient.js +2 -2
- package/lib/models/BundleRegistration.js +2 -2
- package/lib/models/Clickwrap.js +2 -2
- package/lib/models/DnsRecord.js +2 -2
- package/lib/models/EmailIncomingMessage.js +2 -2
- package/lib/models/Errors.js +2 -2
- package/lib/models/ExternalEvent.js +2 -2
- package/lib/models/File.js +2 -2
- package/lib/models/FileAction.js +2 -2
- package/lib/models/FileComment.js +2 -2
- package/lib/models/FileCommentReaction.js +2 -2
- package/lib/models/FileMigration.js +2 -2
- package/lib/models/FileUploadPart.js +2 -2
- package/lib/models/Folder.js +2 -2
- package/lib/models/FormField.js +2 -2
- package/lib/models/FormFieldSet.js +2 -2
- package/lib/models/GpgKey.js +2 -2
- package/lib/models/Group.js +2 -2
- package/lib/models/GroupUser.js +2 -2
- package/lib/models/History.js +2 -2
- package/lib/models/HistoryExport.js +2 -2
- package/lib/models/HistoryExportResult.js +2 -2
- package/lib/models/Image.js +2 -2
- package/lib/models/InboxRecipient.js +2 -2
- package/lib/models/InboxRegistration.js +2 -2
- package/lib/models/InboxUpload.js +2 -2
- package/lib/models/Invoice.js +2 -2
- package/lib/models/InvoiceLineItem.js +2 -2
- package/lib/models/IpAddress.js +2 -2
- package/lib/models/Lock.js +2 -2
- package/lib/models/Message.js +2 -2
- package/lib/models/MessageComment.js +2 -2
- package/lib/models/MessageCommentReaction.js +2 -2
- package/lib/models/MessageReaction.js +2 -2
- package/lib/models/Notification.js +2 -2
- package/lib/models/Payment.js +2 -2
- package/lib/models/PaymentLineItem.js +2 -2
- package/lib/models/Permission.js +2 -2
- package/lib/models/Preview.js +2 -2
- package/lib/models/Priority.js +2 -2
- package/lib/models/Project.js +2 -2
- package/lib/models/PublicIpAddress.js +2 -2
- package/lib/models/PublicKey.js +2 -2
- package/lib/models/RemoteBandwidthSnapshot.js +2 -2
- package/lib/models/RemoteServer.js +2 -2
- package/lib/models/RemoteServerConfigurationFile.js +2 -2
- package/lib/models/Request.js +2 -2
- package/lib/models/Session.js +2 -2
- package/lib/models/SettingsChange.js +2 -2
- package/lib/models/SftpHostKey.js +2 -2
- package/lib/models/ShareGroup.js +2 -2
- package/lib/models/ShareGroupMember.js +2 -2
- package/lib/models/Site.js +2 -2
- package/lib/models/Snapshot.js +2 -2
- package/lib/models/SsoStrategy.js +2 -2
- package/lib/models/Status.js +2 -2
- package/lib/models/Style.js +2 -2
- package/lib/models/UsageDailySnapshot.js +2 -2
- package/lib/models/UsageSnapshot.js +2 -2
- package/lib/models/User.js +2 -2
- package/lib/models/UserCipherUse.js +2 -2
- package/lib/models/UserRequest.js +2 -2
- package/lib/models/WebhookTest.js +2 -2
- package/lib/utils/pathNormalizer.js +5 -4
- package/lib/utils/pathNormalizer.test.js +18 -0
- package/package.json +1 -1
- package/src/Files.js +1 -1
- package/src/utils/pathNormalizer.js +7 -6
- package/src/utils/pathNormalizer.test.js +22 -0
@@ -198,7 +198,7 @@ var transliterate = function transliterate(str) {
|
|
198
198
|
// converting the path to UTF-8 is not necessary in JS as it's the default
|
199
199
|
var normalize = function normalize(path) {
|
200
200
|
// Remove any characters with byte value of 0
|
201
|
-
var cleaned = (path
|
201
|
+
var cleaned = (typeof path === 'string' ? path : '').replace(/\0/g, '');
|
202
202
|
|
203
203
|
// Convert any backslash (\) characters to a forward slash (/)
|
204
204
|
cleaned = cleaned.replace(/\\/g, '/');
|
@@ -239,13 +239,13 @@ var normalizeForComparison = function normalizeForComparison(path) {
|
|
239
239
|
return normalized;
|
240
240
|
};
|
241
241
|
var same = function same(path1, path2) {
|
242
|
-
return normalizeForComparison(path1) === normalizeForComparison(path2);
|
242
|
+
return typeof path1 === 'string' && typeof path2 === 'string' && normalizeForComparison(path1) === normalizeForComparison(path2);
|
243
243
|
};
|
244
244
|
var startsWith = function startsWith(path1, path2) {
|
245
|
-
return normalizeForComparison(path1).startsWith(normalizeForComparison(path2));
|
245
|
+
return typeof path1 === 'string' && typeof path2 === 'string' && normalizeForComparison(path1).startsWith(normalizeForComparison(path2));
|
246
246
|
};
|
247
247
|
var keyLookup = function keyLookup(object, path) {
|
248
|
-
var key = Object.keys(object).find(function (key) {
|
248
|
+
var key = Object.keys(object || {}).find(function (key) {
|
249
249
|
return same(key, path);
|
250
250
|
});
|
251
251
|
return typeof key === 'string' ? object[key] : undefined;
|
@@ -253,6 +253,7 @@ var keyLookup = function keyLookup(object, path) {
|
|
253
253
|
var pathNormalizer = {
|
254
254
|
keyLookup: keyLookup,
|
255
255
|
normalize: normalize,
|
256
|
+
normalizeForComparison: normalizeForComparison,
|
256
257
|
same: same,
|
257
258
|
startsWith: startsWith
|
258
259
|
};
|
@@ -15,6 +15,24 @@ describe('pathNormalizer', function () {
|
|
15
15
|
expect(_pathNormalizer.default.startsWith(input, startOfExpected)).toBe(true);
|
16
16
|
});
|
17
17
|
});
|
18
|
+
it('handles non-string params', function () {
|
19
|
+
expect(_pathNormalizer.default.normalize([])).toBe('');
|
20
|
+
expect(_pathNormalizer.default.normalize({})).toBe('');
|
21
|
+
expect(_pathNormalizer.default.normalize(null)).toBe('');
|
22
|
+
expect(_pathNormalizer.default.normalize(undefined)).toBe('');
|
23
|
+
expect(_pathNormalizer.default.same([], '')).toBe(false);
|
24
|
+
expect(_pathNormalizer.default.same(null, '')).toBe(false);
|
25
|
+
expect(_pathNormalizer.default.same([], null)).toBe(false);
|
26
|
+
expect(_pathNormalizer.default.same(undefined, undefined)).toBe(false);
|
27
|
+
expect(_pathNormalizer.default.startsWith(null, '')).toBe(false);
|
28
|
+
expect(_pathNormalizer.default.startsWith(null, [])).toBe(false);
|
29
|
+
expect(_pathNormalizer.default.startsWith([], null)).toBe(false);
|
30
|
+
expect(_pathNormalizer.default.startsWith(undefined, undefined)).toBe(false);
|
31
|
+
expect(_pathNormalizer.default.keyLookup(null, '')).toBe(undefined);
|
32
|
+
expect(_pathNormalizer.default.keyLookup(null, [])).toBe(undefined);
|
33
|
+
expect(_pathNormalizer.default.keyLookup([], null)).toBe(undefined);
|
34
|
+
expect(_pathNormalizer.default.keyLookup(undefined, undefined)).toBe(undefined);
|
35
|
+
});
|
18
36
|
it('looks up keys in a map', function () {
|
19
37
|
var map = {
|
20
38
|
'': {
|
package/package.json
CHANGED
package/src/Files.js
CHANGED
@@ -193,7 +193,7 @@ const transliterate = str =>
|
|
193
193
|
// converting the path to UTF-8 is not necessary in JS as it's the default
|
194
194
|
const normalize = path => {
|
195
195
|
// Remove any characters with byte value of 0
|
196
|
-
let cleaned = (path
|
196
|
+
let cleaned = (typeof path === 'string' ? path : '').replace(/\0/g, '')
|
197
197
|
|
198
198
|
// Convert any backslash (\) characters to a forward slash (/)
|
199
199
|
cleaned = cleaned.replace(/\\/g, '/')
|
@@ -237,20 +237,21 @@ const normalizeForComparison = path => {
|
|
237
237
|
return normalized
|
238
238
|
}
|
239
239
|
|
240
|
-
const same = (path1, path2) =>
|
241
|
-
normalizeForComparison(path1) === normalizeForComparison(path2)
|
240
|
+
const same = (path1, path2) => typeof path1 === 'string' && typeof path2 === 'string'
|
241
|
+
&& normalizeForComparison(path1) === normalizeForComparison(path2)
|
242
242
|
|
243
|
-
const startsWith = (path1, path2) =>
|
244
|
-
normalizeForComparison(path1).startsWith(normalizeForComparison(path2))
|
243
|
+
const startsWith = (path1, path2) => typeof path1 === 'string' && typeof path2 === 'string'
|
244
|
+
&& normalizeForComparison(path1).startsWith(normalizeForComparison(path2))
|
245
245
|
|
246
246
|
const keyLookup = (object, path) => {
|
247
|
-
const key = Object.keys(object).find(key => same(key, path))
|
247
|
+
const key = Object.keys(object || {}).find(key => same(key, path))
|
248
248
|
return typeof key === 'string' ? object[key] : undefined
|
249
249
|
}
|
250
250
|
|
251
251
|
const pathNormalizer = {
|
252
252
|
keyLookup,
|
253
253
|
normalize,
|
254
|
+
normalizeForComparison,
|
254
255
|
same,
|
255
256
|
startsWith,
|
256
257
|
}
|
@@ -12,6 +12,28 @@ describe('pathNormalizer', () => {
|
|
12
12
|
})
|
13
13
|
})
|
14
14
|
|
15
|
+
it('handles non-string params', () => {
|
16
|
+
expect(pathNormalizer.normalize([])).toBe('')
|
17
|
+
expect(pathNormalizer.normalize({})).toBe('')
|
18
|
+
expect(pathNormalizer.normalize(null)).toBe('')
|
19
|
+
expect(pathNormalizer.normalize(undefined)).toBe('')
|
20
|
+
|
21
|
+
expect(pathNormalizer.same([], '')).toBe(false)
|
22
|
+
expect(pathNormalizer.same(null, '')).toBe(false)
|
23
|
+
expect(pathNormalizer.same([], null)).toBe(false)
|
24
|
+
expect(pathNormalizer.same(undefined, undefined)).toBe(false)
|
25
|
+
|
26
|
+
expect(pathNormalizer.startsWith(null, '')).toBe(false)
|
27
|
+
expect(pathNormalizer.startsWith(null, [])).toBe(false)
|
28
|
+
expect(pathNormalizer.startsWith([], null)).toBe(false)
|
29
|
+
expect(pathNormalizer.startsWith(undefined, undefined)).toBe(false)
|
30
|
+
|
31
|
+
expect(pathNormalizer.keyLookup(null, '')).toBe(undefined)
|
32
|
+
expect(pathNormalizer.keyLookup(null, [])).toBe(undefined)
|
33
|
+
expect(pathNormalizer.keyLookup([], null)).toBe(undefined)
|
34
|
+
expect(pathNormalizer.keyLookup(undefined, undefined)).toBe(undefined)
|
35
|
+
})
|
36
|
+
|
15
37
|
it('looks up keys in a map', () => {
|
16
38
|
const map = {
|
17
39
|
'': { list: true },
|