Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

标题中特殊字符报错 #145

Open
verygoodlee opened this issue Apr 6, 2024 · 2 comments
Open

标题中特殊字符报错 #145

verygoodlee opened this issue Apr 6, 2024 · 2 comments

Comments

@verygoodlee
Copy link

verygoodlee commented Apr 6, 2024

  • 操作系统:windows11
  • 浏览器:edge

https://www.bilibili.com/video/BV1Qr42147pQ
image
看报错位置是在这里,可能是标题中 𝘾𝙝𝙚𝙘𝙠𝙡𝙞𝙨𝙩 造成的,不是常规的英文字符,有点特殊

let index = (maxLength / encodeTitle.length) * title.length;
title = title.substring(0, index);
encodeTitle = encodeURIComponent(title + "...");

edit:
控制台输入'𝘾𝙝𝙚𝙘𝙠𝙡𝙞𝙨𝙩'.length竟然是18,一个字符占2个长度
image
应该是它造成substring()截在了半个字符的位置,导致encodeURIComponent()报错
image

@verygoodlee
Copy link
Author

换成 #125 中的截取方式没问题,抓异常的方式还是很稳定

@LuckyPuppy514
Copy link
Owner

处理起来还有点麻烦,还是先用 #125 的办法了 😂
v4.0.7 已更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants