This commit is contained in:
Leon van Kammen 2024-07-12 17:52:26 +00:00
parent e3b68cb572
commit 0a931a8242
3 changed files with 9 additions and 3 deletions

View file

@ -23,6 +23,8 @@ xrf.navigator.to = (url,flags,loader,data) => {
URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos
URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"") URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"")
let hashbus = xrf.hashbus let hashbus = xrf.hashbus
console.dir({URI1:xrf.navigator.URI,URI2:URI})
debugger
xrf.navigator.URI = URI xrf.navigator.URI = URI
let {directory,file,fragment,fileExt} = URI; let {directory,file,fragment,fileExt} = URI;

View file

@ -19,5 +19,6 @@
{"fn":"url","data":"a/b#foo=bar", "expect":{ "fn":"testURL", "input":"hash.foo","out":"bar"},"label":"test URL hash #mycustom == foo"}, {"fn":"url","data":"a/b#foo=bar", "expect":{ "fn":"testURL", "input":"hash.foo","out":"bar"},"label":"test URL hash #mycustom == foo"},
{"fn":"url","data":"./../../xyz", "expect":{ "fn":"testURLBrowse", "input":"path","out":"/bar/flop/c/d/./../../xyz"},"label":"test URL relative path"}, {"fn":"url","data":"./../../xyz", "expect":{ "fn":"testURLBrowse", "input":"path","out":"/bar/flop/c/d/./../../xyz"},"label":"test URL relative path"},
{"fn":"url","data":"./../../xyz", "expect":{ "fn":"testURLBrowse", "input":"path","out":"/bar/flop/c/d/./../../xyz"},"label":"test URL relative path"}, {"fn":"url","data":"./../../xyz", "expect":{ "fn":"testURLBrowse", "input":"path","out":"/bar/flop/c/d/./../../xyz"},"label":"test URL relative path"},
{"fn":"url","data":"#foo", "expect":{ "fn":"testURLBrowse", "input":"directory","out":"/bar/flop/c/d/./../../xyz"},"label":"test URL relative path"},
{"fn":"url","data":"a/b?index.glb#foo=bar://foo/flop.gltf", "expect":{ "fn":"testURL", "input":"directory","out":"/a/b"},"label":"test URLhash with protocol"} {"fn":"url","data":"a/b?index.glb#foo=bar://foo/flop.gltf", "expect":{ "fn":"testURL", "input":"directory","out":"/a/b"},"label":"test URLhash with protocol"}
] ]

View file

@ -125,7 +125,7 @@ class URI {
// The almighty regexp (courtesy of http://blog.stevenlevithan.com/archives/parseuri) // The almighty regexp (courtesy of http://blog.stevenlevithan.com/archives/parseuri)
var r : EReg = ~/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; var r : EReg = ~/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
if( stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != '/' ){ if( stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != '/' && stringUrl.charAt(0) != '#' ){
stringUrl = "/" + stringUrl; // workaround for relative urls stringUrl = "/" + stringUrl; // workaround for relative urls
} }
@ -431,7 +431,7 @@ class URI {
directory = url.directory; directory = url.directory;
} }
if (newURI.directory != null) if (newURI.directory != null && newURI.source.charAt(0) != "#")
{ {
if( newUrl.charAt(0) != '/' && newUrl.indexOf("://") == -1 ){ if( newUrl.charAt(0) != '/' && newUrl.indexOf("://") == -1 ){
var stripRelative : EReg = ~/\.\/.*/; var stripRelative : EReg = ~/\.\/.*/;
@ -443,13 +443,16 @@ class URI {
} }
resultURI.directory = directory; resultURI.directory = directory;
trace("1:"+newURI.file);
trace("2:"+url.file);
if (newURI.file != null) if (newURI.file != null)
{ {
resultURI.file = newURI.file; resultURI.file = newURI.file;
}else{ }else{
resultURI.file = url.file; resultURI.file = url.file;
} }
trace("3:"+resultURI.file);
resultURI.path = resultURI.directory + resultURI.file; resultURI.path = resultURI.directory + resultURI.file;