WIP: use es-modules
This commit is contained in:
parent
ec5b050496
commit
baef49f116
143 changed files with 738 additions and 55 deletions
|
|
@ -1,4 +1,5 @@
|
|||
'use strict';
|
||||
import Ox from './Namespace.js';
|
||||
|
||||
/*@
|
||||
Ox.char <f> Alias for String.fromCharCode
|
||||
|
|
@ -265,17 +266,30 @@ Ox.parseURL <f> Takes a URL, returns its components
|
|||
'?a=0&b=1'
|
||||
@*/
|
||||
Ox.parseURL = (function() {
|
||||
var a = document.createElement('a'),
|
||||
keys = ['hash', 'host', 'hostname', 'origin',
|
||||
'pathname', 'port', 'protocol', 'search'];
|
||||
return function(string) {
|
||||
var ret = {};
|
||||
a.href = string;
|
||||
keys.forEach(function(key) {
|
||||
ret[key] = a[key];
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
const keys = [
|
||||
'hash', 'host', 'hostname', 'origin',
|
||||
'pathname', 'port', 'protocol', 'search'
|
||||
];
|
||||
if (typeof document == 'undefined') {
|
||||
return function(string) {
|
||||
const a = new URL(string);
|
||||
var ret = {};
|
||||
keys.forEach(function(key) {
|
||||
ret[key] = a[key];
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
var a = document.createElement('a');
|
||||
return function(string) {
|
||||
var ret = {};
|
||||
a.href = string;
|
||||
keys.forEach(function(key) {
|
||||
ret[key] = a[key];
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
// FIXME: can we get rid of this?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue