mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 08:26:22 +00:00
fix: better null domain fallback logic
This commit is contained in:
parent
4488f9ae8a
commit
954df13aa2
@ -938,7 +938,7 @@ self.sendUploadResponse = async (req, res, user, result) => {
|
|||||||
files: result.map(file => {
|
files: result.map(file => {
|
||||||
const map = {
|
const map = {
|
||||||
name: file.name,
|
name: file.name,
|
||||||
url: `${config.domain}/${file.name}`
|
url: `${config.domain ? `${config.domain}/` : ''}${file.name}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a temporary upload, add expiry date
|
// If a temporary upload, add expiry date
|
||||||
|
@ -678,9 +678,9 @@ page.getUploads = (params = {}) => {
|
|||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
// Build full URLs
|
// Build full URLs
|
||||||
files[i].file = `${basedomain}/${files[i].name}`
|
files[i].file = `${basedomain || window.location.origin}/${files[i].name}`
|
||||||
if (files[i].thumb) {
|
if (files[i].thumb) {
|
||||||
files[i].thumb = `${basedomain}/${files[i].thumb}`
|
files[i].thumb = `${basedomain ? `${basedomain}/` : ''}${files[i].thumb}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine types
|
// Determine types
|
||||||
@ -1621,7 +1621,7 @@ page.getAlbums = (params = {}) => {
|
|||||||
page.cache = {}
|
page.cache = {}
|
||||||
|
|
||||||
const users = response.data.users
|
const users = response.data.users
|
||||||
const homeDomain = response.data.homeDomain
|
const homeDomain = response.data.homeDomain || window.location.origin
|
||||||
|
|
||||||
if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)
|
if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)
|
||||||
const pagination = page.paginate(response.data.count, 25, params.pageNum)
|
const pagination = page.paginate(response.data.count, 25, params.pageNum)
|
||||||
|
@ -692,7 +692,11 @@ page.updateTemplate = (file, response) => {
|
|||||||
const link = file.previewElement.querySelector('.link')
|
const link = file.previewElement.querySelector('.link')
|
||||||
const a = link.querySelector('a')
|
const a = link.querySelector('a')
|
||||||
const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')
|
const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')
|
||||||
a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url
|
let url = response.url
|
||||||
|
if (!/^https?:\/\//i.test(url)) {
|
||||||
|
url = `${window.location.origin}/${url}`
|
||||||
|
}
|
||||||
|
a.href = a.innerHTML = clipboard.dataset.clipboardText = url
|
||||||
|
|
||||||
link.classList.remove('is-hidden')
|
link.classList.remove('is-hidden')
|
||||||
clipboard.parentElement.classList.remove('is-hidden')
|
clipboard.parentElement.classList.remove('is-hidden')
|
||||||
|
Loading…
Reference in New Issue
Block a user