Skip to content

fix: resolve XML attributes, URL resolution, client API gaps, and exports - #280

Merged
natelindev merged 2 commits into
mainfrom
fix/repo-issues-audit
Sep 19, 2026
Merged

natelindev merged 2 commits into
mainfrom
fix/repo-issues-audit

Conversation

@natelindev

Copy link
Copy Markdown
Owner

Summary of Changes

This PR addresses several latent bugs and inconsistencies identified during a repository-wide audit:

1. XML Attribute Propagation & Root Namespaces

  • Issue: davRequest placed init.attributes at the document root level ({ _declaration, _attributes, ...body }), which xml-js in compact mode ignores. Custom namespaces and attributes passed in init.attributes were dropped. Furthermore, makeCollection omitted root DAV namespace attributes on <mkcol>.
  • Fix: Propagate init.attributes into each root element of body in davRequest (merging with existing element attributes). Added standard DAV namespaces to body.mkcol._attributes in makeCollection.

2. Relative URL Resolution & Trailing Slashes

  • Issue: When collection or root URLs lacked trailing slashes (e.g. https://example.com/cal/user), WHATWG new URL('1.ics', base) resolution treated the final path segment as a filename and dropped it, resulting in incorrect target paths (https://example.com/cal/1.ics).
  • Fix: Added ensureTrailingSlash helper and applied it across account, calendar, addressBook, and collection when resolving relative hrefs, child object URLs, and collection paths.

3. Account Href Extraction Robustness

  • Issue: fetchPrincipalUrl and fetchHomeUrl only accepted pure strings for hrefs. CalDAV/CardDAV servers returning { _cdata: string } or arrays of hrefs (RFC 4791 allows multi-valued calendar-home-set) resulted in cannot find homeUrl / cannot find principalUrl.
  • Fix: Implemented extractHref supporting strings, CDATA objects, and arrays.

4. Calendar & AddressBook Query Edge Cases

  • Issue:
    • In fetchCalendarObjects and fetchVCards, empty or whitespace hrefs caused new URL() to throw uncaught exceptions.
    • When useMultiGet: false and objectUrls was specified, calendarObjectResults was not filtered to match the requested objectUrls.
  • Fix: Filtered out falsy/whitespace strings prior to URL construction and filtered results against objectUrls when useMultiGet: false.

5. Client API Completeness (freeBusyQuery)

  • Issue: freeBusyQuery was exported from ./calendar but omitted from both createDAVClient and DAVClient.
  • Fix: Added freeBusyQuery to createDAVClient return object and DAVClient class.

6. Public Exports & Type Declarations

  • Issue: Key utilities (serviceDiscovery, fetchPrincipalUrl, fetchHomeUrl, urlMatches, ensureTrailingSlash, excludeHeaders, mergeHeaders, ICALObjects) and sync overload types were not re-exported from src/index.ts.
  • Fix: Exported these symbols and types from src/index.ts. Added comprehensive export verification tests in src/__tests__/unit/index.test.ts.

7. Type Helper Null Safety

  • Issue: Passing null or undefined to hasFields or findMissingFieldNames caused uncaught TypeError: Cannot convert undefined or null to object.
  • Fix: Added null/undefined guards while maintaining support for property checks on primitive types.

8. Tooling & Documentation

  • Issue: Deprecated pnpm.overrides configuration emitted warnings under pnpm 10; docs typo in fetchCalendarObjects (calendarObjectUrls instead of objectUrls).
  • Fix: Migrated pnpm.overrides to root overrides in both root and docs/package.json, and fixed the documentation typo.

Verification

  • Unit tests: 19 test files passed (291 tests passed).
  • Linting: pnpm lint passed with 0 errors.
  • Typecheck: pnpm typecheck passed with 0 errors.
  • Build: pnpm build completed successfully.
  • Docs tests: pnpm --dir docs test passed with 0 errors.

…orts

- Propagate XML root element attributes properly in davRequest and makeCollection
- Ensure trailing slashes on base URLs when resolving relative hrefs and object filenames
- Robustly parse principal and home set hrefs (arrays, objects, strings)
- Guard type helpers hasFields and findMissingFieldNames against null/undefined
- Expose freeBusyQuery method on DAVClient and createDAVClient return object
- Export missing public symbols and overload types in index.ts
- Fix documentation typo and eliminate pnpm 10 deprecation warnings
@vercel

vercel Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
tsdav Ignored Ignored Preview Sep 19, 2026 4:45pm UTC

@natelindev
natelindev merged commit 2106b3e into main Sep 19, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Production — 15b7974e Deployed Sep 19, 2026 by natelindev via automated-test (22) #1391
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant