also parse if only strings are allowed

This commit is contained in:
j 2018-03-13 18:09:01 +05:30
parent a171fbebea
commit d9695f8540

View file

@ -607,12 +607,18 @@ Ox.URL = function(options) {
return ret;
}
function hasOnlyStringType(spanTypes) {
var types = Ox.unique(Ox.values(spanTypes));
return types.length == 1 && types[0] == 'string';
}
function isNumericalSpan(str) {
return str.split(',').every(function(str) {
return /^[0-9-\.:]+$/.test(str);
});
}
function getSpanType(str, types) {
Ox.Log('Core', 'getSpanType', str, types)
var canBeDate = types.indexOf('date') > -1,
@ -922,7 +928,7 @@ Ox.URL = function(options) {
spanTypes = self.options.spanType[state.type][
!state.item ? 'list' : 'item'
];
if (isNumericalSpan(parts[0])) {
if (isNumericalSpan(parts[0]) || hasOnlyStringType(spanTypes)) {
// test for numerical span
// if no view is given then parse the span anyway,
// but make sure the span type could match a view