forked from josdejong/jsoneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature josdejong#144 improved regex for stripping JSONP
- Loading branch information
1 parent
57691e5
commit 03292d9
Showing
4 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
* | ||
* @author Jos de Jong, <[email protected]> | ||
* @version 3.2.0 | ||
* @date 2015-02-11 | ||
* @date 2015-02-12 | ||
*/ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
|
@@ -1486,10 +1486,14 @@ return /******/ (function(modules) { // webpackBootstrap | |
//If JSON starts with a function (Carachters/digist/"_-"), remove this function. | ||
//This is usefull for "stripping" JSONP objects to become JSON | ||
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}] | ||
if(jsonString.match(/[\da-zA-Z_-\s]+\(+\s*/)){ | ||
var jsonStringTemp = jsonString.replace(/[\da-zA-Z_-\s]+\(+\s*/,'') | ||
jsonString = jsonStringTemp.replace(/\s*\)(?!.*[\)])[;\s]*/g,''); | ||
} | ||
var match = jsonString.match(/^\s*[\dA-z_$]+\s*\(([\s\S]*)\)\s*;?\s*$/); | ||
if (match) { | ||
var jsonString = match[1]; | ||
} | ||
// if(jsonString.match(/[\da-zA-Z_-\s]+\(+\s*/)){ | ||
// var jsonStringTemp = jsonString.replace(/[\da-zA-Z_-\s]+\(+\s*/,'') | ||
// jsonString = jsonStringTemp.replace(/\s*\)(?!.*[\)])[;\s]*/g,''); | ||
// } | ||
|
||
return jsonString; | ||
}; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters