diff --git a/lib/services/ics-retriever.js b/lib/services/ics-retriever.js index 5092bbe..c41faf7 100644 --- a/lib/services/ics-retriever.js +++ b/lib/services/ics-retriever.js @@ -14,7 +14,7 @@ const extractEventDataFromHTML = (html, url, { logger }) => { const eventData = { ...rawEventData, - url: rawEventData.url || url, + url: rawEventData.url || getNormalizedUrl(url), } return eventData diff --git a/test/services/ics-retriever.spec.js b/test/services/ics-retriever.spec.js index f8d6414..564978e 100644 --- a/test/services/ics-retriever.spec.js +++ b/test/services/ics-retriever.spec.js @@ -133,6 +133,29 @@ describe(retrieveICS, () => { }) + it('should normalize URL when parsing event data based on DOM', () => { + const html = ` + + + Test + + +
+
+ + + ` + + const { url } = extractEventDataFromHTML( + html, + '123', { + logger, + }) + + expect(url).to.equal('https://mobile.facebook.com/events/123') + }) + + it('should throw parser error if no event data is found', () => { const html = `