import appSettings from '@/core/config/app-settings'

/** 相对路径补全为可播放/可展示的绝对地址 */
export function absolutizeMedia(path) {
	if (!path) return ''
	if (/^https?:\/\//i.test(path)) return path
	if (path.startsWith('//')) return `https:${path}`
	const root = String(appSettings.cdnurl || '').replace(/\/$/, '')
	const tail = path.startsWith('/') ? path : `/${path}`
	return root ? `${root}${tail}` : tail
}