owncloud / davclient.js

WebDAV, CalDAV and CardDAV client for javascript
BSD 3-Clause "New" or "Revised" License
51 stars 19 forks source link

parseURL can't handle IPv6 addresses #23

Open georgehrke opened 8 years ago

georgehrke commented 8 years ago

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 commented 8 years ago

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

georgehrke commented 8 years ago

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

evert commented 8 years ago

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?

tcitworld commented 8 years ago

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

staabm commented 8 years ago

the URL Interface seems no to be Edge compatible

tcitworld commented 8 years ago

From what I see here, most of it works.

staabm commented 8 years ago

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.

PVince81 commented 8 years ago

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

evert commented 8 years ago

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.