-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ignore URLs that the app does not own #1487
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Ignore URLs that the app does not own |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,15 @@ export default function (test) { | |
|
||
const requests2 = await capture_requests(() => app.goto('/routing/prefetched')); | ||
assert.equal(requests2, []); | ||
|
||
try { | ||
await app.prefetch('https://example.com'); | ||
throw new Error('Error was not thrown'); | ||
} catch (e) { | ||
assert.ok( | ||
e.message.includes('Attempted to prefetch a URL that does not belong to this app') | ||
); | ||
} | ||
} | ||
}); | ||
|
||
|
@@ -200,4 +209,13 @@ export default function (test) { | |
assert.equal(await page.textContent('h2'), 'y-z'); | ||
} | ||
); | ||
|
||
test( | ||
'ignores navigation to URLs the app does not own', | ||
'/routing', | ||
async ({ page, clicknav }) => { | ||
await clicknav('[href="https://www.google.com"]'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's some chance that this will cause tests to fail on the CI. I have no idea what Google will do if it thinks it's being hit by an automated bot. Maybe we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extra safe version would probably be to spin up another server on localhost on a different port, but that might be more hassle than it's worth, especially if this is a fix you're trying to get out quickly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it works fine locally, so presumably google has no problem with it. agree that it's a potential source of flakiness, but realistically if google.com is inaccessible the internet probably has bigger problems that day |
||
assert.equal(await page.url(), 'https://www.google.com/'); | ||
} | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's worth trying to shorten this message the one below to save bytes shipped to the client such as:
'Attempted to prefetch external URL'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think 'external' is correct — nytimes.com isn't external to nytimes.com/interactive/2021/us/covid-cases.html, in the normal sense of that word in a URL context