Procházet zdrojové kódy

@uppy/companion: remove `isobject` from dependencies (#3948)

Antoine du Hamel před 2 roky
rodič
revize
3fed45a749

+ 0 - 1
packages/@uppy/companion/package.json

@@ -47,7 +47,6 @@
     "grant": "4.7.0",
     "helmet": "^4.6.0",
     "ipaddr.js": "^2.0.1",
-    "isobject": "3.0.1",
     "jsonwebtoken": "8.5.1",
     "lodash.merge": "^4.6.2",
     "mime-types": "2.1.25",

+ 4 - 5
packages/@uppy/companion/src/server/Uploader.js

@@ -1,7 +1,6 @@
 // eslint-disable-next-line max-classes-per-file
 const tus = require('tus-js-client')
 const { randomUUID } = require('node:crypto')
-const isObject = require('isobject')
 const validator = require('validator')
 const request = require('request')
 const { pipeline: pipelineCb } = require('node:stream')
@@ -78,17 +77,17 @@ function validateOptions (options) {
   }
 
   // validate fieldname
-  if (options.fieldname && typeof options.fieldname !== 'string') {
+  if (options.fieldname != null && typeof options.fieldname !== 'string') {
     throw new ValidationError('fieldname must be a string')
   }
 
   // validate metadata
-  if (options.metadata != null) {
-    if (!isObject(options.metadata)) throw new ValidationError('metadata must be an object')
+  if (options.metadata != null && typeof options.metadata !== 'object') {
+    throw new ValidationError('metadata must be an object')
   }
 
   // validate headers
-  if (options.headers && !isObject(options.headers)) {
+  if (options.headers != null && typeof options.headers !== 'object') {
     throw new ValidationError('headers must be an object')
   }
 

+ 1 - 2
packages/@uppy/companion/src/server/header-blacklist.js

@@ -1,4 +1,3 @@
-const isObject = require('isobject')
 const logger = require('./logger')
 
 /**
@@ -50,7 +49,7 @@ const isForbiddenHeader = (header) => {
 }
 
 module.exports = (headers) => {
-  if (!isObject(headers)) {
+  if (headers == null || typeof headers !== 'object' || Array.isArray(headers)) {
     return {}
   }
 

+ 7 - 8
yarn.lock

@@ -10180,7 +10180,6 @@ __metadata:
     helmet: ^4.6.0
     into-stream: ^6.0.0
     ipaddr.js: ^2.0.1
-    isobject: 3.0.1
     jest: ^27.0.6
     jsonwebtoken: 8.5.1
     lodash.merge: ^4.6.2
@@ -24609,13 +24608,6 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
-"isobject@npm:3.0.1, isobject@npm:^3.0.0, isobject@npm:^3.0.1":
-  version: 3.0.1
-  resolution: "isobject@npm:3.0.1"
-  checksum: db85c4c970ce30693676487cca0e61da2ca34e8d4967c2e1309143ff910c207133a969f9e4ddb2dc6aba670aabce4e0e307146c310350b298e74a31f7d464703
-  languageName: node
-  linkType: hard
-
 "isobject@npm:^2.0.0":
   version: 2.1.0
   resolution: "isobject@npm:2.1.0"
@@ -24625,6 +24617,13 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
+"isobject@npm:^3.0.0, isobject@npm:^3.0.1":
+  version: 3.0.1
+  resolution: "isobject@npm:3.0.1"
+  checksum: db85c4c970ce30693676487cca0e61da2ca34e8d4967c2e1309143ff910c207133a969f9e4ddb2dc6aba670aabce4e0e307146c310350b298e74a31f7d464703
+  languageName: node
+  linkType: hard
+
 "isobject@npm:^4.0.0":
   version: 4.0.0
   resolution: "isobject@npm:4.0.0"