video-flow-toon/src/utils/replaceUrl.ts
2026-04-02 23:49:05 +08:00

13 lines
398 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default function replaceUrl(url: string): string {
if (typeof url !== 'string' || !url.trim()) return '';
let cleanedPath = '';
try {
const pathname = new URL(url).pathname;
cleanedPath = pathname.replace(/^\/oss/, '');
} catch (e) {
// 如果不是有效的URL则直接返回原字符串
cleanedPath = url;
}
return cleanedPath;
}