@uppy/companion-client
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0
'use strict'; | ||
const qsStringify = require('qs-stringify'); | ||
const RequestClient = require('./RequestClient'); | ||
@@ -9,3 +7,3 @@ | ||
const _getName = id => { | ||
const getName = id => { | ||
return id.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(' '); | ||
@@ -19,3 +17,3 @@ }; | ||
this.id = this.provider; | ||
this.name = this.opts.name || _getName(this.id); | ||
this.name = this.opts.name || getName(this.id); | ||
this.pluginId = this.opts.pluginId; | ||
@@ -71,5 +69,3 @@ this.tokenKey = `companion-${this.pluginId}-auth-token`; | ||
let strigifiedQueries = qsStringify(queries); | ||
strigifiedQueries = strigifiedQueries ? `?${strigifiedQueries}` : strigifiedQueries; | ||
return `${this.hostname}/${this.id}/connect${strigifiedQueries}`; | ||
return `${this.hostname}/${this.id}/connect?${new URLSearchParams(queries)}`; | ||
} | ||
@@ -125,9 +121,7 @@ | ||
plugin.opts.companionAllowedHosts = pattern; | ||
} else if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) { | ||
// does not start with https:// | ||
plugin.opts.companionAllowedHosts = `https://${opts.companionUrl.replace(/^\/\//, '')}`; | ||
} else { | ||
// does not start with https:// | ||
if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) { | ||
plugin.opts.companionAllowedHosts = `https://${opts.companionUrl.replace(/^\/\//, '')}`; | ||
} else { | ||
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin; | ||
} | ||
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin; | ||
} | ||
@@ -134,0 +128,0 @@ |
@@ -160,3 +160,3 @@ 'use strict'; | ||
}), _class.VERSION = "2.0.0-alpha.0", _class.defaultHeaders = { | ||
}), _class.VERSION = "2.0.0", _class.defaultHeaders = { | ||
Accept: 'application/json', | ||
@@ -163,0 +163,0 @@ 'Content-Type': 'application/json', |
@@ -5,3 +5,3 @@ 'use strict'; | ||
const _getName = id => { | ||
const getName = id => { | ||
return id.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(' '); | ||
@@ -15,3 +15,3 @@ }; | ||
this.id = this.provider; | ||
this.name = this.opts.name || _getName(this.id); | ||
this.name = this.opts.name || getName(this.id); | ||
this.pluginId = this.opts.pluginId; | ||
@@ -18,0 +18,0 @@ } |
{ | ||
"name": "@uppy/companion-client", | ||
"description": "Client library for communication with Companion. Intended for use in Uppy plugins.", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -24,7 +24,6 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/utils": "^4.0.0-alpha.0", | ||
"namespace-emitter": "^2.0.1", | ||
"qs-stringify": "^1.1.0" | ||
"@uppy/utils": "^4.0.0", | ||
"namespace-emitter": "^2.0.1" | ||
}, | ||
"gitHead": "113b627dd0ef5aa5d198dc309dda05da2117dfe5" | ||
"gitHead": "ab771cbe1cd87affd87c97bc983b19058e2e72bd" | ||
} |
'use strict' | ||
const qsStringify = require('qs-stringify') | ||
const RequestClient = require('./RequestClient') | ||
const tokenStorage = require('./tokenStorage') | ||
const _getName = (id) => { | ||
const getName = (id) => { | ||
return id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') | ||
@@ -16,3 +15,3 @@ } | ||
this.id = this.provider | ||
this.name = this.opts.name || _getName(this.id) | ||
this.name = this.opts.name || getName(this.id) | ||
this.pluginId = this.opts.pluginId | ||
@@ -63,5 +62,3 @@ this.tokenKey = `companion-${this.pluginId}-auth-token` | ||
let strigifiedQueries = qsStringify(queries) | ||
strigifiedQueries = strigifiedQueries ? `?${strigifiedQueries}` : strigifiedQueries | ||
return `${this.hostname}/${this.id}/connect${strigifiedQueries}` | ||
return `${this.hostname}/${this.id}/connect?${new URLSearchParams(queries)}` | ||
} | ||
@@ -116,9 +113,7 @@ | ||
plugin.opts.companionAllowedHosts = pattern | ||
} else if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) { | ||
// does not start with https:// | ||
plugin.opts.companionAllowedHosts = `https://${opts.companionUrl.replace(/^\/\//, '')}` | ||
} else { | ||
// does not start with https:// | ||
if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) { | ||
plugin.opts.companionAllowedHosts = `https://${opts.companionUrl.replace(/^\/\//, '')}` | ||
} else { | ||
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin | ||
} | ||
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin | ||
} | ||
@@ -125,0 +120,0 @@ |
@@ -5,3 +5,3 @@ 'use strict' | ||
const _getName = (id) => { | ||
const getName = (id) => { | ||
return id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') | ||
@@ -15,3 +15,3 @@ } | ||
this.id = this.provider | ||
this.name = this.opts.name || _getName(this.id) | ||
this.name = this.opts.name || getName(this.id) | ||
this.pluginId = this.opts.pluginId | ||
@@ -18,0 +18,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
0
70080
1002
3
- Removedqs-stringify@^1.1.0
- Removedqs-stringify@1.2.1(transitive)
Updated@uppy/utils@^4.0.0