normalize URL when parsing event number from HTML file
This commit is contained in:
parent
b56fffc308
commit
cfd939a668
|
@ -14,7 +14,7 @@ const extractEventDataFromHTML = (html, url, { logger }) => {
|
|||
|
||||
const eventData = {
|
||||
...rawEventData,
|
||||
url: rawEventData.url || url,
|
||||
url: rawEventData.url || getNormalizedUrl(url),
|
||||
}
|
||||
|
||||
return eventData
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue