normalize URL when parsing event number from HTML file

This commit is contained in:
Ondřej Synáček 2020-07-23 17:23:04 +02:00
parent b56fffc308
commit cfd939a668
2 changed files with 24 additions and 1 deletions

View File

@ -14,7 +14,7 @@ const extractEventDataFromHTML = (html, url, { logger }) => {
const eventData = {
...rawEventData,
url: rawEventData.url || url,
url: rawEventData.url || getNormalizedUrl(url),
}
return eventData

View File

@ -133,6 +133,29 @@ describe(retrieveICS, () => {
})
it('should normalize URL when parsing event data based on DOM', () => {
const html = `
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="event_summary">
</div>
</body>
</html>
`
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 = `
<html>