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 = {
|
const eventData = {
|
||||||
...rawEventData,
|
...rawEventData,
|
||||||
url: rawEventData.url || url,
|
url: rawEventData.url || getNormalizedUrl(url),
|
||||||
}
|
}
|
||||||
|
|
||||||
return eventData
|
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', () => {
|
it('should throw parser error if no event data is found', () => {
|
||||||
const html = `
|
const html = `
|
||||||
<html>
|
<html>
|
||||||
|
|
Loading…
Reference in New Issue