Skip to content

Commit 480d566

Browse files
committed
Fix example fetch URL handling
1 parent f00c994 commit 480d566

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
function fakeFetch(url) {
1212
const urlObj = new URL(url)
1313
let html = ''
14-
if (url.pathname === '/results') {
14+
if (urlObj.pathname === '/results') {
1515
const doc = document.createElement('div')
1616
doc.innerHTML = `<li>Hubot</li><li>BB-8</li><li>Wall-E</li><li>Bender</li>`
17-
const q = url.searchParams.get('q')
17+
const q = urlObj.searchParams.get('q')
1818
for (const el of doc.querySelectorAll('li')) {
1919
if (q !== '' && !el.textContent.toLowerCase().match(q.toLowerCase())) el.remove()
2020
}
2121
html = doc.innerHTML
22-
} else if (url.pathname === '/marquee') {
23-
html = `<marquee>${url.searchParams.get('q') || '🐈 Nothing to preview 🐈'}</marquee>`
22+
} else if (urlObj.pathname === '/marquee') {
23+
html = `<marquee>${urlObj.searchParams.get('q') || '🐈 Nothing to preview 🐈'}</marquee>`
2424
}
2525
const promiseHTML = new Promise(resolve => resolve(html))
2626
return new Promise(resolve => resolve({ok: true, text: () => promiseHTML}))

0 commit comments

Comments
 (0)