fix web书架读书章节内容存在多张图片时代理图片url中的bookUrl参数未encodeURIComponent导致的图片无法访问 (#5136)
Co-authored-by: 17683954109@163.com <17683954109@163.com>
This commit is contained in:
co-authored by
17683954109@163.com <17683954109@163.com>
parent
d7c2cedd5e
commit
dad8dfcada
@@ -305,9 +305,10 @@ const getContent = (index: number, reloadChapter = true, chapterPos = 0) => {
|
||||
if (res.data.isSuccess) {
|
||||
const data = res.data.data
|
||||
const content = data.split(/\n+/)
|
||||
const urlEncodedBookUrl = encodeURIComponent(bookUrl)
|
||||
for (let i = 0; i < content.length; i++) {
|
||||
if (!/^\s*<img[^>]*src[^>]+>$/.test(content[i])) {
|
||||
content[i] = content[i].replace(new RegExp('img src="', 'g'), `img src="/image?url=${bookUrl}&path=`);
|
||||
content[i] = content[i].replace(new RegExp('img src="', 'g'), `img src="/image?url=${urlEncodedBookUrl}&path=`);
|
||||
}
|
||||
}
|
||||
chapterData.value.push({ index, content, title })
|
||||
|
||||
Reference in New Issue
Block a user