beta release build 0.7.2
This commit is contained in:
parent
31b13aa943
commit
af5fd44ef9
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fluent-reader",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fluent-reader",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2",
|
||||
"description": "Modern desktop RSS reader",
|
||||
"main": "./dist/electron.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -60,6 +60,7 @@ export class WindowManager {
|
|||
webviewTag: true,
|
||||
enableRemoteModule: false,
|
||||
contextIsolation: true,
|
||||
worldSafeExecuteJavaScript: true,
|
||||
spellcheck: false,
|
||||
preload: path.join(app.getAppPath(), (app.isPackaged ? "dist/" : "") + "preload.js")
|
||||
}
|
||||
|
|
|
@ -29,18 +29,22 @@ const rssParser = new Parser({
|
|||
})
|
||||
|
||||
const CHARSET_RE = /charset=([^()<>@,;:\"/[\]?.=\s]*)/i
|
||||
const XML_ENCODING_RE = /^<\?xml.+encoding="(.+)".*\?>\s*\n/i
|
||||
const XML_ENCODING_RE = /^<\?xml.+encoding="(.+)".*?\?>/i
|
||||
export async function decodeFetchResponse(response: Response, isHTML = false) {
|
||||
const buffer = await response.arrayBuffer()
|
||||
const ctype = response.headers.has("content-type") && response.headers.get("content-type")
|
||||
let ctype = response.headers.has("content-type") && response.headers.get("content-type")
|
||||
let charset = (ctype && CHARSET_RE.test(ctype)) ? CHARSET_RE.exec(ctype)[1] : undefined
|
||||
let content = (new TextDecoder(charset)).decode(buffer)
|
||||
if (charset === undefined) {
|
||||
if (isHTML) {
|
||||
const dom = domParser.parseFromString(content, "text/html")
|
||||
charset = dom.querySelector("meta[charset]")?.getAttribute("charset")?.toLowerCase()
|
||||
if (!charset) {
|
||||
ctype = dom.querySelector("meta[http-equiv='Content-Type']")?.getAttribute("content")
|
||||
charset = ctype && CHARSET_RE.test(ctype) && CHARSET_RE.exec(ctype)[1].toLowerCase()
|
||||
}
|
||||
} else {
|
||||
charset = (XML_ENCODING_RE.test(content) && XML_ENCODING_RE.exec(content)[1])?.toLowerCase()
|
||||
charset = XML_ENCODING_RE.test(content) && XML_ENCODING_RE.exec(content)[1].toLowerCase()
|
||||
}
|
||||
if (charset && charset !== "utf-8" && charset !== "utf8") {
|
||||
content = (new TextDecoder(charset)).decode(buffer)
|
||||
|
|
Loading…
Reference in New Issue