Ox.URL: fix and update tests
This commit is contained in:
parent
d3f39c29f2
commit
35947ab77b
1 changed files with 19 additions and 19 deletions
|
@ -56,16 +56,23 @@ Ox.URL <f> URL controller
|
|||
{id: 'population', type: 'integer'}
|
||||
],
|
||||
getHash: function(state, callback) {
|
||||
if (
|
||||
state.hash && state.hash.anchor
|
||||
&& state.hash.anchor.length > 1
|
||||
) {
|
||||
if (state.hash.query) {
|
||||
if (state.hash) {
|
||||
if (state.hash.anchor == 'invalid') {
|
||||
delete state.hash.anchor;
|
||||
} else {
|
||||
}
|
||||
if (state.hash.query) {
|
||||
state.hash.query = state.hash.query.filter(function(v) {
|
||||
return v.key != 'invalid'
|
||||
});
|
||||
if (Ox.isEmpty(state.hash.query)) {
|
||||
delete state.hash.query;
|
||||
}
|
||||
}
|
||||
if (Ox.isEmpty(state.hash)) {
|
||||
delete state.hash;
|
||||
}
|
||||
}
|
||||
callback();
|
||||
},
|
||||
getItem: function(state, str, callback) {
|
||||
state.item = /^\d+$/.test(str) ? str : '';
|
||||
|
@ -225,14 +232,6 @@ Ox.URL <f> URL controller
|
|||
operator: '&'
|
||||
}
|
||||
},
|
||||
'/#?k=v&l=w': {
|
||||
hash: {
|
||||
query: [
|
||||
{key: 'k', value: 'v'},
|
||||
{key: 'l', value: 'w'}
|
||||
]
|
||||
}
|
||||
},
|
||||
'/#a?k=v&l=w': {
|
||||
hash: {
|
||||
anchor: 'a',
|
||||
|
@ -242,7 +241,7 @@ Ox.URL <f> URL controller
|
|||
]
|
||||
}
|
||||
},
|
||||
'/#invalid?a=[1,2]&b=true&n=1.2&o={"k":"v"}&s1="foo"&s2=bar': {
|
||||
'/#?a=[1,2]&b=true&n=1.2&o={"k":"v"}&s1="foo"&s2=bar': {
|
||||
hash: {
|
||||
query: [
|
||||
{key: 'a', value: [1, 2]},
|
||||
|
@ -253,7 +252,8 @@ Ox.URL <f> URL controller
|
|||
{key: 's2', value: 'bar'}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
'/#invalid?invalid=true': {}
|
||||
};
|
||||
</script>
|
||||
> !!Ox.test.url.parse('/', function(o) { Ox.test(o, Ox.test.result['/']); })
|
||||
|
@ -284,11 +284,11 @@ Ox.URL <f> URL controller
|
|||
true
|
||||
> !!Ox.test.url.parse('/population>0&(name=a*|name=*z)', function(o) { Ox.test(o, Ox.test.result['/population>0&(name=a*|name=*z)']); })
|
||||
true
|
||||
> !!Ox.test.url.parse('/#?k=v&l=w', function(o) { Ox.test(o, Ox.test.result['/#?k=v&l=w']); })
|
||||
true
|
||||
> !!Ox.test.url.parse('/#a?k=v&l=w', function(o) { Ox.test(o, Ox.test.result['/#a?k=v&l=w']); })
|
||||
true
|
||||
> !!Ox.test.url.parse('/#invalid?a=[1,2]&b=true&n=1.2&o={"k":"v"}&s1="foo"&s2=bar', function(o) { Ox.test(o, Ox.test.result['/#invalid?a=[1,2]&b=true&n=1.2&o={"k":"v"}&s1="foo"&s2=bar']); })
|
||||
> !!Ox.test.url.parse('/#?a=[1,2]&b=true&n=1.2&o={"k":"v"}&s1="foo"&s2=bar', function(o) { Ox.test(o, Ox.test.result['/#?a=[1,2]&b=true&n=1.2&o={"k":"v"}&s1="foo"&s2=bar']); })
|
||||
true
|
||||
> !!Ox.test.url.parse('/#invalid?invalid=true', function(o) { Ox.test(o, Ox.test.result['/#invalid?invalid=true']); })
|
||||
true
|
||||
@*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue