work in progress [might break]
This commit is contained in:
parent
4f15c6b6cf
commit
7e39b79eb6
3 changed files with 22 additions and 28 deletions
28
src/Test.hx
28
src/Test.hx
|
|
@ -45,7 +45,9 @@ class Test {
|
||||||
if( item.expect.fn == "testPropertyAssign" ) valid = res.exists(item.expect.input) && item.expect.out == res.get(item.expect.input).is( XRF.PROP_BIND) ;
|
if( item.expect.fn == "testPropertyAssign" ) valid = res.exists(item.expect.input) && item.expect.out == res.get(item.expect.input).is( XRF.PROP_BIND) ;
|
||||||
if( item.expect.fn == "testBrowserOverride" ) valid = item.expect.out == (URI.parse(item.data,XRF.NAVIGATOR)).exists(item.expect.input);
|
if( item.expect.fn == "testBrowserOverride" ) valid = item.expect.out == (URI.parse(item.data,XRF.NAVIGATOR)).exists(item.expect.input);
|
||||||
if( item.expect.fn == "testEmbedOverride" ) valid = item.expect.out == (URI.parse(item.data,XRF.METADATA)).exists(item.expect.input);
|
if( item.expect.fn == "testEmbedOverride" ) valid = item.expect.out == (URI.parse(item.data,XRF.METADATA)).exists(item.expect.input);
|
||||||
if( item.expect.fn == "testURL" ) valid = testURL( item.data, item.expect.input, item.expect.out );
|
if( item.expect.fn == "testURL" ) valid = testURL( item.data, item.expect.input, item.expect.out, false );
|
||||||
|
if( item.expect.fn == "testURLHash" ) valid = testURL( item.data, item.expect.input, item.expect.out, false );
|
||||||
|
if( item.expect.fn == "testURLBrowse" ) valid = testURL( item.data, item.expect.input, item.expect.out, true );
|
||||||
|
|
||||||
if( item.expect.fn == "equal.string" ) valid = res.get(item.expect.input) && item.expect.out == res.get(item.expect.input).string;
|
if( item.expect.fn == "equal.string" ) valid = res.get(item.expect.input) && item.expect.out == res.get(item.expect.input).string;
|
||||||
if( item.expect.fn == "equal.x" ) valid = equalX(res,item);
|
if( item.expect.fn == "equal.x" ) valid = equalX(res,item);
|
||||||
|
|
@ -86,24 +88,12 @@ class Test {
|
||||||
static public function testURL( url:String, attr:String, output:String, browserMode: Bool = false): Bool {
|
static public function testURL( url:String, attr:String, output:String, browserMode: Bool = false): Bool {
|
||||||
var URL = xrfragment.URL;
|
var URL = xrfragment.URL;
|
||||||
var url = URL.parse(url,false);
|
var url = URL.parse(url,false);
|
||||||
trace("url:"+url.url);
|
var parts:Array<String> = attr.split(".");
|
||||||
trace("source:"+url.source);
|
if( parts.length > 1 && parts[0] == "hash" && url.hash.exists( parts[1]) ){
|
||||||
trace("scheme:"+url.scheme);
|
return url.hash.get( parts[1] ) == output;
|
||||||
trace("auth:"+url.authority);
|
}else{
|
||||||
trace("uinfo:"+url.userInfo);
|
if( Reflect.hasField(url, attr) && Reflect.field(url,attr) == output ) return true;
|
||||||
trace("u:"+url.user);
|
}
|
||||||
trace("pw:"+url.password);
|
|
||||||
trace("host:"+url.host);
|
|
||||||
trace("port:"+url.port);
|
|
||||||
trace("relative:"+url.relative);
|
|
||||||
trace("path:"+url.path);
|
|
||||||
trace("directory:"+url.directory);
|
|
||||||
trace("file:"+url.file);
|
|
||||||
trace("query:"+url.query);
|
|
||||||
trace("browserMode:"+url.browserMode);
|
|
||||||
trace("fragment:"+url.fragment);
|
|
||||||
trace("hash:"+url.hash);
|
|
||||||
if( Reflect.hasField(url, attr) && Reflect.field(url,attr) == output ) return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,6 @@
|
||||||
{"fn":"url","data":"http://foo.com?foo=1#mypredefinedview&another", "expect":{ "fn":"testPredefinedView", "input":"mypredefinedview","out":true},"label":"test predefined view executed (multiple)"},
|
{"fn":"url","data":"http://foo.com?foo=1#mypredefinedview&another", "expect":{ "fn":"testPredefinedView", "input":"mypredefinedview","out":true},"label":"test predefined view executed (multiple)"},
|
||||||
{"fn":"url","data":"http://foo.com?foo=1#mycustom=foo", "expect":{ "fn":"testParsed", "input":"mycustom","out":true},"label":"test custom property"},
|
{"fn":"url","data":"http://foo.com?foo=1#mycustom=foo", "expect":{ "fn":"testParsed", "input":"mycustom","out":true},"label":"test custom property"},
|
||||||
{"fn":"url","data":"http://foo.com?foo=1#mycustom=foo", "expect":{ "fn":"testURL", "input":"scheme","out":"http"},"label":"test URL scheme http"},
|
{"fn":"url","data":"http://foo.com?foo=1#mycustom=foo", "expect":{ "fn":"testURL", "input":"scheme","out":"http"},"label":"test URL scheme http"},
|
||||||
{"fn":"url","data":"http://foo.com/a/b?foo=1#mycustom=foo", "expect":{ "fn":"testURL", "input":"path","out":"/a/b"},"label":"test URL path /a/b"}
|
{"fn":"url","data":"http://foo.com/a/b?foo=1#mycustom=foo", "expect":{ "fn":"testURL", "input":"path","out":"/a/b"},"label":"test URL path /a/b"},
|
||||||
|
{"fn":"url","data":"http://foo.com/a/b?foo=1#mycustom=foo", "expect":{ "fn":"testURL", "input":"hash.mycustom","out":"foo"},"label":"test URL hash #mycustom == foo"}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ class URL
|
||||||
public var browserMode: Bool;
|
public var browserMode: Bool;
|
||||||
public var fragment : String;
|
public var fragment : String;
|
||||||
public var hash : haxe.DynamicAccess<Dynamic>;
|
public var hash : haxe.DynamicAccess<Dynamic>;
|
||||||
|
public var XRF : haxe.DynamicAccess<Dynamic>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class constructor
|
* class constructor
|
||||||
|
|
@ -77,7 +78,6 @@ class URL
|
||||||
|
|
||||||
var url:URL = new URL();
|
var url:URL = new URL();
|
||||||
url.browserMode = browserMode;
|
url.browserMode = browserMode;
|
||||||
trace(url);
|
|
||||||
|
|
||||||
// Use reflection to set each part
|
// Use reflection to set each part
|
||||||
for (i in 0..._parts.length)
|
for (i in 0..._parts.length)
|
||||||
|
|
@ -95,17 +95,20 @@ class URL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url.hash = {};
|
||||||
if( url.fragment.length > 0 ){
|
if( url.fragment.length > 0 ){
|
||||||
trace("ja");
|
url.XRF = xrfragment.URI.parse( "#"+url.fragment, 0 );
|
||||||
url.hash = xrfragment.URI.parse( url.fragment, 0 );
|
var key:String;
|
||||||
trace(url.hash.get('mycustom'));
|
for( key in url.XRF.keys() ){
|
||||||
}else url.hash = {};
|
var v:haxe.DynamicAccess<Dynamic> = url.XRF.get(key);
|
||||||
|
url.hash[key] = v.get("string");
|
||||||
|
}
|
||||||
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize an URL object into an
|
* Serialize an URl OBJect into an
|
||||||
* URL string
|
* URL string
|
||||||
*/
|
*/
|
||||||
public static function toString(url:URL):String
|
public static function toString(url:URL):String
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue