fix(frontend): 视频链接缺协议头时自动补 https:// 而非直接拒绝#423
Open
pumpkinperson996 wants to merge 1 commit into
Open
Conversation
用户从各处摘抄的链接常常没有 https:// 前缀(如 bilibili.com/...), 表单校验用 new URL() 解析会直接失败,提示"请输入正确的视频链接"。 校验时对无 scheme 的输入先补 https:// 再解析;提交时同样补全后再发 给后端(本地视频路径除外)。已有明确 scheme 的输入不受影响,ftp:// 等非 http(s) 协议仍被拒绝。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
用户粘贴的视频链接如果没有协议头(例如
bilibili.com/list/watchlater/?bvid=BV...或www.bilibili.com/video/BV...),前端表单校验中的new URL(video_url)会抛异常,直接提示"请输入正确的视频链接"。从聊天记录、笔记等处摘抄的链接经常缺协议头,这类输入其实意图明确。修复
新增
withScheme()辅助函数:输入不含任何 scheme(^[a-z][a-z0-9+.-]*://)时自动补https://。new URL(withScheme(video_url)),无协议头的合法链接可通过校验video_url同样补全后再发给后端(platform === 'local'的本地路径不处理)ftp://等非 http(s) 协议仍按原逻辑拒绝改动仅
NoteForm.tsx一个文件。🤖 Generated with Claude Code