Skip to content

Commit

Permalink
Remove unrelated whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Dec 5, 2023
1 parent ca5a315 commit 1c9aea5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions packages/@uppy/companion-client/src/RequestClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import AuthError from './AuthError.js'
import packageJson from '../package.json'

// Remove the trailing slash so we can always safely append /xyz.
function stripSlash(url) {
function stripSlash (url) {
return url.replace(/\/$/, '')
}

Expand All @@ -31,7 +31,7 @@ class HttpError extends Error {
}
}

async function handleJSONResponse(res) {
async function handleJSONResponse (res) {
if (res.status === authErrorStatusCode) {
throw new AuthError()
}
Expand Down Expand Up @@ -60,28 +60,28 @@ export default class RequestClient {

#companionHeaders

constructor(uppy, opts) {
constructor (uppy, opts) {
this.uppy = uppy
this.opts = opts
this.onReceiveResponse = this.onReceiveResponse.bind(this)
this.#companionHeaders = opts?.companionHeaders
}

setCompanionHeaders(headers) {
setCompanionHeaders (headers) {
this.#companionHeaders = headers
}

[Symbol.for('uppy test: getCompanionHeaders')]() {
[Symbol.for('uppy test: getCompanionHeaders')] () {
return this.#companionHeaders
}

get hostname() {
get hostname () {
const { companion } = this.uppy.getState()
const host = this.opts.companionUrl
return stripSlash(companion && companion[host] ? companion[host] : host)
}

async headers(emptyRequest = false) {
async headers (emptyRequest = false) {
const defaultHeaders = {
Accept: 'application/json',
...(emptyRequest ? undefined : {
Expand All @@ -96,7 +96,7 @@ export default class RequestClient {
}
}

onReceiveResponse({ headers }) {
onReceiveResponse ({ headers }) {
const state = this.uppy.getState()
const companion = state.companion || {}
const host = this.opts.companionUrl
Expand All @@ -109,15 +109,15 @@ export default class RequestClient {
}
}

#getUrl(url) {
#getUrl (url) {
if (/^(https?:|)\/\//.test(url)) {
return url
}
return `${this.hostname}/${url}`
}

/** @protected */
async request({ path, method = 'GET', data, skipPostResponse, signal }) {
async request ({ path, method = 'GET', data, skipPostResponse, signal }) {
try {
const headers = await this.headers(!data)
const response = await fetchWithNetworkError(this.#getUrl(path), {
Expand All @@ -140,21 +140,21 @@ export default class RequestClient {
}
}

async get(path, options = undefined) {
async get (path, options = undefined) {
// TODO: remove boolean support for options that was added for backward compatibility.
// eslint-disable-next-line no-param-reassign
if (typeof options === 'boolean') options = { skipPostResponse: options }
return this.request({ ...options, path })
}

async post(path, data, options = undefined) {
async post (path, data, options = undefined) {
// TODO: remove boolean support for options that was added for backward compatibility.
// eslint-disable-next-line no-param-reassign
if (typeof options === 'boolean') options = { skipPostResponse: options }
return this.request({ ...options, path, method: 'POST', data })
}

async delete(path, data = undefined, options) {
async delete (path, data = undefined, options) {
// TODO: remove boolean support for options that was added for backward compatibility.
// eslint-disable-next-line no-param-reassign
if (typeof options === 'boolean') options = { skipPostResponse: options }
Expand All @@ -174,7 +174,7 @@ export default class RequestClient {
* @param {*} options
* @returns
*/
async uploadRemoteFile(file, reqBody, options = {}) {
async uploadRemoteFile (file, reqBody, options = {}) {
try {
const { signal, getQueue } = options

Expand Down Expand Up @@ -253,7 +253,7 @@ export default class RequestClient {
*
* @param {{ file: UppyFile, queue: RateLimitedQueue, signal: AbortSignal }} file
*/
async #awaitRemoteFileUpload({ file, queue, signal }) {
async #awaitRemoteFileUpload ({ file, queue, signal }) {
let removeEventHandlers

const { capabilities } = this.uppy.getState()
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/config/companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const defaultOptions = {
/**
* @param {object} companionOptions
*/
function getMaskableSecrets(companionOptions) {
function getMaskableSecrets (companionOptions) {
const secrets = []
const { providerOptions, customProviders, s3 } = companionOptions

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/controllers/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const oAuthState = require('../helpers/oauth-state')
* @param {object} req
* @param {object} res
*/
module.exports = function connect(req, res) {
module.exports = function connect (req, res) {
const { secret } = req.companion.options
let state = oAuthState.generateState(secret)
if (req.query.state) {
Expand Down

0 comments on commit 1c9aea5

Please sign in to comment.