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

解析下载链接出错 #101

Open
zhanglianxin opened this issue Feb 19, 2023 · 1 comment
Open

解析下载链接出错 #101

zhanglianxin opened this issue Feb 19, 2023 · 1 comment

Comments

@zhanglianxin
Copy link

zhanglianxin commented Feb 19, 2023

你好,我发现网页程序里是支持传入 title 查询参数自定义保存文件名的,但是
getSource() 方法中 this.url = href.split('?source=')[1] 会导致将其他查询参数一起解析出来。

建议使用 new URL(location.href).searchParams.get('source') 解析资源链接,为了避免影响其他方法继续使用 this.url 解析变量,可以将 source 单独提取成员变量出来。

@zhanglianxin
Copy link
Author

或者说,解析 title 变量时,不应再从 this.url 取值,而是从原始的 URL 取值。

- this.title = new URL(this.url).searchParams.get('title') || this.title // 获取视频标题
+ this.title = new URL(location.href).searchParams.get('title') || this.title // 获取视频标题

即使如此, href.split('?source=')[1] 也不太优雅,如果是外部调用,source 不在查询参数的第一项的位置时,就解析失效了。

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

1 participant