Files
RSSHub/lib/v2/lxixsxa/jsonpHelper.js
ri1ken 69cd00d1a4 feat(route): add LiSA (#10755)
* feat(route): add LiSA

* Add a linebreak before next heading

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* fix title

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* use art-template

* fix docs link

* rename folder

* fix router url according to new folder name

* fix router path & example path in doc

* append radar detectable source

* Update lib/v2/lxixsxa/templates/disco.art

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/lxixsxa/templates/info.art

Co-authored-by: Weijian Li <ri1ken@r1ks-mba.local>
2022-09-10 20:49:43 +08:00

20 lines
550 B
JavaScript

function parseJSONP(jsonpData) {
try {
const startPos = jsonpData.indexOf('({');
const endPos = jsonpData.lastIndexOf('})');
let jsonString = jsonpData.substring(startPos + 1, endPos + 1);
// remove escaped single quotes since they are not valid json
jsonString = jsonString.replace(/\\'/g, "'");
return JSON.parse(jsonString);
} catch (e) {
const error = new Error(`Failed to convert jsonp to json. ${e.message}`);
throw error;
}
}
module.exports = {
parseJSONP,
};