refactor: Simplify audio URL handling in jobApi by removing redundant base URL concatenation

This commit is contained in:
2026-02-04 13:18:39 +08:00
parent d8ab716171
commit a694ead4b8

View File

@@ -344,16 +344,14 @@ export const jobApi = {
if (audioPath.startsWith('http')) { if (audioPath.startsWith('http')) {
if (audioPath.includes('localhost') || audioPath.includes('127.0.0.1')) { if (audioPath.includes('localhost') || audioPath.includes('127.0.0.1')) {
const url = new URL(audioPath) const url = new URL(audioPath)
return `${import.meta.env.VITE_API_URL}${url.pathname}` return url.pathname
} }
return audioPath return audioPath
} else { } else {
const baseUrl = import.meta.env.VITE_API_URL return audioPath.startsWith('/') ? audioPath : `/${audioPath}`
const normalizedPath = audioPath.startsWith('/') ? audioPath : `/${audioPath}`
return `${baseUrl}${normalizedPath}`
} }
} else { } else {
return `${import.meta.env.VITE_API_URL}${API_ENDPOINTS.JOBS.AUDIO(id)}` return API_ENDPOINTS.JOBS.AUDIO(id)
} }
}, },
} }