davclient.js icon indicating copy to clipboard operation
davclient.js copied to clipboard

parseURL can't handle IPv6 addresses

Open georgehrke opened this issue 8 years ago • 9 comments

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

not compatible ipv6 issue 718 owncloud-calendar safari technology preview today at 9 32 35 pm

georgehrke avatar Sep 06 '16 19:09 georgehrke

This might be a solution: https://gist.github.com/jlong/2428561

georgehrke avatar Sep 06 '16 19:09 georgehrke

This would introduce a dependency on the document object though :/

georgehrke avatar Sep 06 '16 19:09 georgehrke

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?

evert avatar Sep 06 '16 21:09 evert

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: "" }

tcitworld avatar Sep 07 '16 07:09 tcitworld

the URL Interface seems no to be Edge compatible

staabm avatar Sep 07 '16 08:09 staabm

From what I see here, most of it works.

tcitworld avatar Sep 07 '16 08:09 tcitworld

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.

staabm avatar Sep 07 '16 08:09 staabm

@evert I never understood why there was this regexp in the first place. Is it for server-side davclient support ?

PVince81 avatar Sep 07 '16 11:09 PVince81

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.

evert avatar Sep 08 '16 17:09 evert