mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add protocol if missing (#8689)
Apparently Hetzner returns locations without protocol. So we add it if necessary.
This commit is contained in:
parent
b23aecc258
commit
d656ac00a1
@ -129,17 +129,22 @@ export const attachments = (config: S3Configured) => {
|
|||||||
}
|
}
|
||||||
const command = new Upload({ client: s3, params })
|
const command = new Upload({ client: s3, params })
|
||||||
const data = await command.done()
|
const data = await command.done()
|
||||||
const { Location } = data
|
let { Location: location } = data
|
||||||
if (!Location) {
|
if (!location) {
|
||||||
throw new Error('File upload did not return `Location`')
|
throw new Error('File upload did not return `Location`')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!location.startsWith('https://') && !location.startsWith('http://')) {
|
||||||
|
// Ensure the location has a protocol. Hetzner does not return a protocol in the location.
|
||||||
|
location = `https://${location}`
|
||||||
|
}
|
||||||
|
|
||||||
let url = ''
|
let url = ''
|
||||||
if (!S3_PUBLIC_GATEWAY) {
|
if (!S3_PUBLIC_GATEWAY) {
|
||||||
url = Location
|
url = location
|
||||||
} else {
|
} else {
|
||||||
const publicLocation = new URL(S3_PUBLIC_GATEWAY)
|
const publicLocation = new URL(S3_PUBLIC_GATEWAY)
|
||||||
publicLocation.pathname = new URL(Location).pathname
|
publicLocation.pathname = new URL(location).pathname
|
||||||
url = publicLocation.href
|
url = publicLocation.href
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user