resolveURL static method
dynamic
resolveURL(
- dynamic url,
- String path
)
Implementation
static resolveURL(url, String path) {
// Invalid URL
// if ( typeof url != 'string' || url == '' ) return '';
if (url is! String || url == '') return '';
// Host Relative URL
final _reg1 = RegExp("^https?://", caseSensitive: false);
if (_reg1.hasMatch(path) &&
RegExp("^/", caseSensitive: false).hasMatch(url)) {
final _reg2 = RegExp("(^https?://[^/]+).*", caseSensitive: false);
final matches = _reg2.allMatches(path);
for (var _match in matches) {
path = path.replaceFirst(_match.group(0)!, _match.group(1)!);
}
print("GLTFHelper.resolveURL todo debug ");
// path = path.replace( RegExp("(^https?:\/\/[^\/]+).*", caseSensitive: false), '$1' );
}
// Absolute URL http://,https://,//
if (RegExp("^(https?:)?//", caseSensitive: false).hasMatch(url)) {
return url;
}
// Data URI
if (RegExp(r"^data:.*,.*$", caseSensitive: false).hasMatch(url)) return url;
// Blob URL
if (RegExp(r"^blob:.*$", caseSensitive: false).hasMatch(url)) return url;
// Relative URL
return path + url;
}