lambdabaa / dav

WebDAV, CalDAV, and CardDAV client for nodejs and the browser.
Mozilla Public License 2.0
304 stars 71 forks source link

Issue retrieving ctag (why fuzzyUrlEquals?) #125

Open marcoancona opened 6 years ago

marcoancona commented 6 years ago

Why fuzzyUrlEquals(one, other) is implemented checking wheter one is included in other and the other way around? Let's consider the request to get the ctag for a calendar collection. This an example of response I get:

<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:fx="http://fruux.com/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav">
  <d:response>
    <d:href>/calendars/a3298212081/</d:href>
    <d:propstat>
      <d:prop>
        <cs:getctag/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/calendars/a3298212081/c7972891-adfe-4ef8-a499-248411cace6e/</d:href>
    <d:propstat>
      <d:prop>
        <cs:getctag>http://sabre.io/ns/sync/15</cs:getctag>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/calendars/a3298212081/f27d33b1-d5bd-4695-9086-8c1607b9f85d/</d:href>
    <d:propstat>
      <d:prop>
        <cs:getctag>http://sabre.io/ns/sync/4</cs:getctag>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

Now the logic of isCollectionDirty() (https://github.com/lambdabaa/dav/blob/2b726a426de513e289da9ac483ce00769297fd67/lib/webdav.js#L82) will match the account, instead of matching the calendar because the account url is a substring of the calendar url. Therefore the ctag will always appear empty. Am I missing something?