@extractus/feed-extractor
Advanced tools
Comparing version 7.1.0 to 7.1.1
{ | ||
"version": "7.1.0", | ||
"version": "7.1.1", | ||
"name": "@extractus/feed-extractor", | ||
@@ -31,12 +31,2 @@ "description": "To read and normalize RSS/ATOM/JSON feed data", | ||
}, | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"build": "node build", | ||
"prepublishOnly": "npm run build", | ||
"pretest": "npm run lint", | ||
"test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true", | ||
"eval": "node eval", | ||
"reset": "node reset" | ||
}, | ||
"dependencies": { | ||
@@ -50,3 +40,4 @@ "bellajs": "^11.1.3", | ||
"esbuild": "^0.20.2", | ||
"eslint": "^8.57.0", | ||
"eslint": "^9.1.1", | ||
"globals": "^15.0.0", | ||
"https-proxy-agent": "^7.0.4", | ||
@@ -64,3 +55,12 @@ "jest": "^29.7.0", | ||
], | ||
"license": "MIT" | ||
} | ||
"license": "MIT", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"build": "node build", | ||
"pretest": "npm run lint", | ||
"test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true", | ||
"eval": "node eval", | ||
"reset": "node reset" | ||
} | ||
} |
@@ -7,3 +7,3 @@ // utils -> linker | ||
return ourl !== null && ourl.protocol.startsWith('http') | ||
} catch (err) { | ||
} catch { | ||
return false | ||
@@ -17,3 +17,3 @@ } | ||
return result.toString() | ||
} catch (err) { | ||
} catch { | ||
return '' | ||
@@ -92,5 +92,5 @@ } | ||
return pureUrl.toString().replace(pureUrl.hash, '') | ||
} catch (err) { | ||
} catch { | ||
return null | ||
} | ||
} |
@@ -19,3 +19,3 @@ // normalizer | ||
return dstr ? (new Date(dstr)).toISOString() : '' | ||
} catch (err) { | ||
} catch { | ||
return '' | ||
@@ -22,0 +22,0 @@ } |
@@ -35,6 +35,11 @@ // utils -> retrieve | ||
const contentType = res.headers.get('content-type') | ||
const text = await res.text() | ||
const buffer = await res.arrayBuffer() | ||
const text = buffer ? Buffer.from(buffer).toString().trim() : '' | ||
if (/(\+|\/)(xml|html)/.test(contentType)) { | ||
return { type: 'xml', text: text.trim(), status, contentType } | ||
const arr = contentType.split('charset=') | ||
const charset = arr.length === 2 ? arr[1].trim() : 'utf8' | ||
const decoder = new TextDecoder(charset) | ||
const xml = decoder.decode(buffer) | ||
return { type: 'xml', text: xml.trim(), status, contentType } | ||
} | ||
@@ -46,3 +51,3 @@ | ||
return { type: 'json', json: data, status, contentType } | ||
} catch (err) { | ||
} catch { | ||
throw new Error('Failed to convert data to JSON object') | ||
@@ -49,0 +54,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
120298
1778
6
29