mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +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 data = await command.done()
|
||||
const { Location } = data
|
||||
if (!Location) {
|
||||
let { Location: location } = data
|
||||
if (!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 = ''
|
||||
if (!S3_PUBLIC_GATEWAY) {
|
||||
url = Location
|
||||
url = location
|
||||
} else {
|
||||
const publicLocation = new URL(S3_PUBLIC_GATEWAY)
|
||||
publicLocation.pathname = new URL(Location).pathname
|
||||
publicLocation.pathname = new URL(location).pathname
|
||||
url = publicLocation.href
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user