From cfd939a6683837060787ff1937254d14496c0860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Thu, 23 Jul 2020 17:23:04 +0200 Subject: [PATCH] normalize URL when parsing event number from HTML file --- lib/services/ics-retriever.js | 2 +- test/services/ics-retriever.spec.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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 = `