Open georgehrke opened 8 years ago
This might be a solution: https://gist.github.com/jlong/2428561
This would introduce a dependency on the document object though :/
Would be good to ditch the ugly regex though! One option to support both server-side and client-side scenarios is to use document
if it's available, and nodejs's url object otherwise...
The only reason we need to parse the url there is for the resolve
method. So maybe there's an alternative to resolve relative urls as well?
Otherwise, there's the URL interface : https://developer.mozilla.org/en/docs/Web/API/URL
new URL('https://github.com/evert/davclient.js/issues/'); URL { href: "https://github.com/evert/davclient.…", origin: "https://github.com", protocol: "https:", username: "", password: "", host: "github.com", hostname: "github.com", port: "", pathname: "/evert/davclient.js/issues/23", search: "" }
the URL Interface seems no to be Edge compatible
ohh, I guess you are right. I tested it in the console without being on the same domain. so I got errors in the dev console because x-domain.. when doing it in the same domain, things look better on IE11.
@evert I never understood why there was this regexp in the first place. Is it for server-side davclient support ?
I think I just kept the php approach, so I needed a simple replacement for parse_url. But yea, I think we only use it for resolve
, so as long as resolve
works correctly, I don't really care.
The current resolve
is imho also flawed at the moment. Based on earlier Sabre\DAV\Client which has since then been fixed to follow the standard better.
The regex in the
parseURL
function can't parse IPv6 addresses.corresponding line: https://github.com/evert/davclient.js/blob/fc7519d2c81f689dba55d0a4504803c5774741ff/lib/client.js#L364