-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from CloudCannon/fix/external-urls
Avoid processing fully qualified URLs when returning results from the web js
- Loading branch information
Showing
5 changed files
with
92 additions
and
7 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,58 @@ | ||
Feature: URL tests | ||
Background: | ||
Given I have the environment variables: | ||
| PAGEFIND_SITE | public | | ||
Given I have a "public/index.html" file with the body: | ||
""" | ||
<p data-url>Nothing</p> | ||
""" | ||
Given I have a "public/package.json" file with the content: | ||
""" | ||
{ | ||
"name": "test", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"pagefind": "file:{{humane_cwd}}/../wrappers/node" | ||
} | ||
} | ||
""" | ||
|
||
@platform-unix | ||
Scenario: Tag pages as external URLs | ||
Given I have a "public/index.js" file with the content: | ||
""" | ||
import * as pagefind from "pagefind"; | ||
const run = async () => { | ||
const { index } = await pagefind.createIndex(); | ||
await index.addCustomRecord({ | ||
url: "https://example.com/external-url/", | ||
content: "Hello World!", | ||
language: "en" | ||
}); | ||
await index.writeFiles(); | ||
console.log(`Successfully wrote files`); | ||
} | ||
run(); | ||
""" | ||
When I run "cd public && npm i && PAGEFIND_BINARY_PATH={{humane_cwd}}/$TEST_BINARY node index.js" | ||
Then I should see "Successfully wrote files" 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 data = await search.results[0].data(); | ||
document.querySelector('[data-url]').innerText = data.url; | ||
} | ||
""" | ||
Then There should be no logs | ||
Then The selector "[data-url]" should contain "https://example.com/external-url/" |
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