Feature #144 improved regex for stripping JSONP
This commit is contained in:
parent
57691e5cb6
commit
03292d9e85
|
@ -24,7 +24,7 @@
|
||||||
*
|
*
|
||||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||||
* @version 3.2.0
|
* @version 3.2.0
|
||||||
* @date 2015-02-11
|
* @date 2015-02-12
|
||||||
*/
|
*/
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
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.
|
//If JSON starts with a function (Carachters/digist/"_-"), remove this function.
|
||||||
//This is usefull for "stripping" JSONP objects to become JSON
|
//This is usefull for "stripping" JSONP objects to become JSON
|
||||||
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}]
|
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}]
|
||||||
if(jsonString.match(/[\da-zA-Z_-\s]+\(+\s*/)){
|
var match = jsonString.match(/^\s*[\dA-z_$]+\s*\(([\s\S]*)\)\s*;?\s*$/);
|
||||||
var jsonStringTemp = jsonString.replace(/[\da-zA-Z_-\s]+\(+\s*/,'')
|
if (match) {
|
||||||
jsonString = jsonStringTemp.replace(/\s*\)(?!.*[\)])[;\s]*/g,'');
|
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;
|
return jsonString;
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -76,9 +76,9 @@ define(function () {
|
||||||
//If JSON starts with a function (Carachters/digist/"_-"), remove this function.
|
//If JSON starts with a function (Carachters/digist/"_-"), remove this function.
|
||||||
//This is usefull for "stripping" JSONP objects to become JSON
|
//This is usefull for "stripping" JSONP objects to become JSON
|
||||||
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}]
|
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}]
|
||||||
if(jsonString.match(/[\da-zA-Z_-\s]+\(+\s*/)){
|
var match = jsonString.match(/^\s*[\dA-z_$]+\s*\(([\s\S]*)\)\s*;?\s*$/);
|
||||||
var jsonStringTemp = jsonString.replace(/[\da-zA-Z_-\s]+\(+\s*/,'')
|
if (match) {
|
||||||
jsonString = jsonStringTemp.replace(/\s*\)(?!.*[\)])[;\s]*/g,'');
|
var jsonString = match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonString;
|
return jsonString;
|
||||||
|
|
Loading…
Reference in New Issue