Skip to content

Commit 091a161

Browse files
committed
v2.0.0-rc.3
1 parent 76f60b6 commit 091a161

10 files changed

+190
-167
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v2.0.0-rc.3
2+
3+
- fixed `urlFilter` not really filtering the urls, only filtering on pathname of urls.
4+
- fixed a bug where fetching on empty calendars/addressBooks returning calendar/addressBook itself as result.
5+
16
## v2.0.0-rc.2
27

38
**improvements**

dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tsdav",
3-
"version": "2.0.0-rc.2",
3+
"version": "2.0.0-rc.3",
44
"description": "WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser",
55
"keywords": [
66
"dav",

dist/tsdav.cjs.js

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -639,19 +639,21 @@ const fetchVCards = (params) => __awaiter(void 0, void 0, void 0, function* () {
639639
depth: '1',
640640
headers,
641641
})).map((res) => { var _a; return (_a = res.href) !== null && _a !== void 0 ? _a : ''; }))
642-
.map((url) => (url.includes('http') ? url : new URL(url, addressBook.url).href))
643-
.map((url) => new URL(url).pathname)
644-
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => url !== addressBook.url));
645-
const vCardResults = yield addressBookMultiGet({
646-
url: addressBook.url,
647-
props: {
648-
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
649-
[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]: {},
650-
},
651-
objectUrls: vcardUrls,
652-
depth: '1',
653-
headers,
654-
});
642+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, addressBook.url).href))
643+
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => url))
644+
.map((url) => new URL(url).pathname);
645+
const vCardResults = vcardUrls.length > 0
646+
? yield addressBookMultiGet({
647+
url: addressBook.url,
648+
props: {
649+
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
650+
[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]: {},
651+
},
652+
objectUrls: vcardUrls,
653+
depth: '1',
654+
headers,
655+
})
656+
: [];
655657
return vCardResults.map((res) => {
656658
var _a, _b, _c, _d, _e, _f;
657659
return ({
@@ -873,34 +875,36 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
873875
depth: '1',
874876
headers,
875877
})).map((res) => { var _a; return (_a = res.href) !== null && _a !== void 0 ? _a : ''; }))
876-
.map((url) => (url.startsWith('http') ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
877-
.map((url) => new URL(url).pathname) // obtain pathname of the url
878-
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))); // filter out non ics calendar objects since apple calendar might have those
879-
const calendarObjectResults = yield calendarMultiGet({
880-
url: calendar.url,
881-
props: {
882-
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
883-
[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
884-
? {
885-
[`${exports.DAVNamespaceShort.CALDAV}:expand`]: {
886-
_attributes: {
887-
start: `${new Date(timeRange.start)
888-
.toISOString()
889-
.slice(0, 19)
890-
.replace(/[-:.]/g, '')}Z`,
891-
end: `${new Date(timeRange.end)
892-
.toISOString()
893-
.slice(0, 19)
894-
.replace(/[-:.]/g, '')}Z`,
878+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
879+
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))) // filter out non ics calendar objects since apple calendar might have those
880+
.map((url) => new URL(url).pathname); // obtain pathname of the url
881+
const calendarObjectResults = calendarObjectUrls.length > 0
882+
? yield calendarMultiGet({
883+
url: calendar.url,
884+
props: {
885+
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
886+
[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
887+
? {
888+
[`${exports.DAVNamespaceShort.CALDAV}:expand`]: {
889+
_attributes: {
890+
start: `${new Date(timeRange.start)
891+
.toISOString()
892+
.slice(0, 19)
893+
.replace(/[-:.]/g, '')}Z`,
894+
end: `${new Date(timeRange.end)
895+
.toISOString()
896+
.slice(0, 19)
897+
.replace(/[-:.]/g, '')}Z`,
898+
},
895899
},
896-
},
897-
}
898-
: {})),
899-
},
900-
objectUrls: calendarObjectUrls,
901-
depth: '1',
902-
headers,
903-
});
900+
}
901+
: {})),
902+
},
903+
objectUrls: calendarObjectUrls,
904+
depth: '1',
905+
headers,
906+
})
907+
: [];
904908
return calendarObjectResults.map((res) => {
905909
var _a, _b, _c, _d, _e, _f;
906910
return ({

dist/tsdav.esm.js

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -630,19 +630,21 @@ const fetchVCards = (params) => __awaiter(void 0, void 0, void 0, function* () {
630630
depth: '1',
631631
headers,
632632
})).map((res) => { var _a; return (_a = res.href) !== null && _a !== void 0 ? _a : ''; }))
633-
.map((url) => (url.includes('http') ? url : new URL(url, addressBook.url).href))
634-
.map((url) => new URL(url).pathname)
635-
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => url !== addressBook.url));
636-
const vCardResults = yield addressBookMultiGet({
637-
url: addressBook.url,
638-
props: {
639-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
640-
[`${DAVNamespaceShort.CARDDAV}:address-data`]: {},
641-
},
642-
objectUrls: vcardUrls,
643-
depth: '1',
644-
headers,
645-
});
633+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, addressBook.url).href))
634+
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => url))
635+
.map((url) => new URL(url).pathname);
636+
const vCardResults = vcardUrls.length > 0
637+
? yield addressBookMultiGet({
638+
url: addressBook.url,
639+
props: {
640+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
641+
[`${DAVNamespaceShort.CARDDAV}:address-data`]: {},
642+
},
643+
objectUrls: vcardUrls,
644+
depth: '1',
645+
headers,
646+
})
647+
: [];
646648
return vCardResults.map((res) => {
647649
var _a, _b, _c, _d, _e, _f;
648650
return ({
@@ -864,34 +866,36 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
864866
depth: '1',
865867
headers,
866868
})).map((res) => { var _a; return (_a = res.href) !== null && _a !== void 0 ? _a : ''; }))
867-
.map((url) => (url.startsWith('http') ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
868-
.map((url) => new URL(url).pathname) // obtain pathname of the url
869-
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))); // filter out non ics calendar objects since apple calendar might have those
870-
const calendarObjectResults = yield calendarMultiGet({
871-
url: calendar.url,
872-
props: {
873-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
874-
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
875-
? {
876-
[`${DAVNamespaceShort.CALDAV}:expand`]: {
877-
_attributes: {
878-
start: `${new Date(timeRange.start)
879-
.toISOString()
880-
.slice(0, 19)
881-
.replace(/[-:.]/g, '')}Z`,
882-
end: `${new Date(timeRange.end)
883-
.toISOString()
884-
.slice(0, 19)
885-
.replace(/[-:.]/g, '')}Z`,
869+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
870+
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))) // filter out non ics calendar objects since apple calendar might have those
871+
.map((url) => new URL(url).pathname); // obtain pathname of the url
872+
const calendarObjectResults = calendarObjectUrls.length > 0
873+
? yield calendarMultiGet({
874+
url: calendar.url,
875+
props: {
876+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
877+
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
878+
? {
879+
[`${DAVNamespaceShort.CALDAV}:expand`]: {
880+
_attributes: {
881+
start: `${new Date(timeRange.start)
882+
.toISOString()
883+
.slice(0, 19)
884+
.replace(/[-:.]/g, '')}Z`,
885+
end: `${new Date(timeRange.end)
886+
.toISOString()
887+
.slice(0, 19)
888+
.replace(/[-:.]/g, '')}Z`,
889+
},
886890
},
887-
},
888-
}
889-
: {})),
890-
},
891-
objectUrls: calendarObjectUrls,
892-
depth: '1',
893-
headers,
894-
});
891+
}
892+
: {})),
893+
},
894+
objectUrls: calendarObjectUrls,
895+
depth: '1',
896+
headers,
897+
})
898+
: [];
895899
return calendarObjectResults.map((res) => {
896900
var _a, _b, _c, _d, _e, _f;
897901
return ({

dist/tsdav.js

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6681,19 +6681,21 @@ const fetchVCards = (params) => __awaiter(void 0, void 0, void 0, function* () {
66816681
depth: '1',
66826682
headers,
66836683
})).map((res) => { var _a; return (_a = res.href) !== null && _a !== void 0 ? _a : ''; }))
6684-
.map((url) => (url.includes('http') ? url : new URL(url, addressBook.url).href))
6685-
.map((url) => new URL(url).pathname)
6686-
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => url !== addressBook.url));
6687-
const vCardResults = yield addressBookMultiGet({
6688-
url: addressBook.url,
6689-
props: {
6690-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
6691-
[`${DAVNamespaceShort.CARDDAV}:address-data`]: {},
6692-
},
6693-
objectUrls: vcardUrls,
6694-
depth: '1',
6695-
headers,
6696-
});
6684+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, addressBook.url).href))
6685+
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => url))
6686+
.map((url) => new URL(url).pathname);
6687+
const vCardResults = vcardUrls.length > 0
6688+
? yield addressBookMultiGet({
6689+
url: addressBook.url,
6690+
props: {
6691+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
6692+
[`${DAVNamespaceShort.CARDDAV}:address-data`]: {},
6693+
},
6694+
objectUrls: vcardUrls,
6695+
depth: '1',
6696+
headers,
6697+
})
6698+
: [];
66976699
return vCardResults.map((res) => {
66986700
var _a, _b, _c, _d, _e, _f;
66996701
return ({
@@ -6915,34 +6917,36 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
69156917
depth: '1',
69166918
headers,
69176919
})).map((res) => { var _a; return (_a = res.href) !== null && _a !== void 0 ? _a : ''; }))
6918-
.map((url) => (url.startsWith('http') ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
6919-
.map((url) => new URL(url).pathname) // obtain pathname of the url
6920-
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))); // filter out non ics calendar objects since apple calendar might have those
6921-
const calendarObjectResults = yield calendarMultiGet({
6922-
url: calendar.url,
6923-
props: {
6924-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
6925-
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
6926-
? {
6927-
[`${DAVNamespaceShort.CALDAV}:expand`]: {
6928-
_attributes: {
6929-
start: `${new Date(timeRange.start)
6930-
.toISOString()
6931-
.slice(0, 19)
6932-
.replace(/[-:.]/g, '')}Z`,
6933-
end: `${new Date(timeRange.end)
6934-
.toISOString()
6935-
.slice(0, 19)
6936-
.replace(/[-:.]/g, '')}Z`,
6920+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
6921+
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))) // filter out non ics calendar objects since apple calendar might have those
6922+
.map((url) => new URL(url).pathname); // obtain pathname of the url
6923+
const calendarObjectResults = calendarObjectUrls.length > 0
6924+
? yield calendarMultiGet({
6925+
url: calendar.url,
6926+
props: {
6927+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
6928+
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
6929+
? {
6930+
[`${DAVNamespaceShort.CALDAV}:expand`]: {
6931+
_attributes: {
6932+
start: `${new Date(timeRange.start)
6933+
.toISOString()
6934+
.slice(0, 19)
6935+
.replace(/[-:.]/g, '')}Z`,
6936+
end: `${new Date(timeRange.end)
6937+
.toISOString()
6938+
.slice(0, 19)
6939+
.replace(/[-:.]/g, '')}Z`,
6940+
},
69376941
},
6938-
},
6939-
}
6940-
: {})),
6941-
},
6942-
objectUrls: calendarObjectUrls,
6943-
depth: '1',
6944-
headers,
6945-
});
6942+
}
6943+
: {})),
6944+
},
6945+
objectUrls: calendarObjectUrls,
6946+
depth: '1',
6947+
headers,
6948+
})
6949+
: [];
69466950
return calendarObjectResults.map((res) => {
69476951
var _a, _b, _c, _d, _e, _f;
69486952
return ({

dist/tsdav.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
lastVersion: 'current',
6060
versions: {
6161
current: {
62-
label: '2.0.0-rc.2',
62+
label: '2.0.0-rc.3',
6363
},
6464
'1.1.6': {
6565
label: '1.1.6',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tsdav",
3-
"version": "2.0.0-rc.2",
3+
"version": "2.0.0-rc.3",
44
"description": "WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser",
55
"keywords": [
66
"dav",

src/addressBook.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,23 @@ export const fetchVCards = async (params: {
145145
})
146146
).map((res) => res.href ?? '')
147147
)
148-
.map((url) => (url.includes('http') ? url : new URL(url, addressBook.url).href))
149-
.map((url) => new URL(url).pathname)
150-
.filter(urlFilter ?? ((url: string): url is string => url !== addressBook.url));
148+
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, addressBook.url).href))
149+
.filter(urlFilter ?? ((url) => url))
150+
.map((url) => new URL(url).pathname);
151151

152-
const vCardResults = await addressBookMultiGet({
153-
url: addressBook.url,
154-
props: {
155-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
156-
[`${DAVNamespaceShort.CARDDAV}:address-data`]: {},
157-
},
158-
objectUrls: vcardUrls,
159-
depth: '1',
160-
headers,
161-
});
152+
const vCardResults =
153+
vcardUrls.length > 0
154+
? await addressBookMultiGet({
155+
url: addressBook.url,
156+
props: {
157+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
158+
[`${DAVNamespaceShort.CARDDAV}:address-data`]: {},
159+
},
160+
objectUrls: vcardUrls,
161+
depth: '1',
162+
headers,
163+
})
164+
: [];
162165

163166
return vCardResults.map((res) => ({
164167
url: new URL(res.href ?? '', addressBook.url).href,

0 commit comments

Comments
 (0)