-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error handling for Pagefind HTML parsing
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Feature: Graceful Pagefind Errors | ||
Background: | ||
Given I have the environment variables: | ||
| PAGEFIND_SOURCE | public | | ||
Given I have a "public/index.html" file with the body: | ||
""" | ||
<p data-url>Nothing</p> | ||
""" | ||
|
||
Scenario: Pagefind gracefully skips pages with parsing ambiguities | ||
Given I have a "public/cat/index.html" file with the body: | ||
""" | ||
<h1>hello world</h1> | ||
""" | ||
Given I have a "public/dog/index.html" file with the body: | ||
""" | ||
<h1>hello world</h1> | ||
<select><xmp><script>"use strict";</script></select> | ||
""" | ||
When I run my program | ||
Then I should see "Running Pagefind" in stdout | ||
Then I should see "Failed to parse file public/dog/index.html" in stdout | ||
Then I should see the file "public/_pagefind/pagefind.js" | ||
When I serve the "public" directory | ||
When I load "/" | ||
When I evaluate: | ||
""" | ||
async function() { | ||
let pagefind = await import("/_pagefind/pagefind.js"); | ||
let search = await pagefind.search("world"); | ||
let results = await Promise.all(search.results.map(r => r.data())); | ||
document.querySelector('[data-url]').innerText = results.map(r => r.url).sort().join(', '); | ||
} | ||
""" | ||
Then There should be no logs | ||
Then The selector "[data-url]" should contain "/cat/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters