Repository navigation
fix(connectors): harden website connector sitemap, robots and resume handling #10556
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
Merged
+700
−150
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a3c1e8d
fix(connectors): harden website connector sitemap, robots and resume …
waleedlatif1 3c47910
fix(connectors): website page decoding, robots cut and shared listing…
waleedlatif1 b01efad
fix(connectors): website robots read stops at its limit; meta charset…
waleedlatif1 f0171f1
fix(connectors): website robots.txt keeps the configured header on sa…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,50 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { decodePage, robotsHeaderNoindex } from '@/connectors/website/page' | ||
|
|
||
| const html = (head: string, text: string) => `<html><head>${head}</head><body>${text}</body></html>` | ||
|
|
||
| describe('website page decoding', () => { | ||
| it('lets a byte order mark override a declared charset', () => { | ||
| const body = Buffer.concat([ | ||
| Buffer.from([0xff, 0xfe]), | ||
| Buffer.from(html('', 'Crème'), 'utf16le'), | ||
| ]) | ||
| expect(decodePage(body, 'text/html; charset=iso-8859-1')).toContain('Crème') | ||
| }) | ||
|
|
||
| it('reads a meta-declared UTF-16 page as UTF-8, as the HTML spec does', () => { | ||
| const body = Buffer.from(html('<meta charset="utf-16">', 'Crème'), 'utf8') | ||
| expect(decodePage(body, 'text/html')).toContain('Crème') | ||
| }) | ||
|
|
||
| it('reads only a charset attribute or Content-Type declaration, not charset text elsewhere', () => { | ||
| const body = Buffer.from( | ||
| html('<meta name="description" content="Set charset=windows-1252 in your editor">', 'Crème'), | ||
| 'utf8' | ||
| ) | ||
| expect(decodePage(body, 'text/html')).toContain('Crème') | ||
| const declared = Buffer.from( | ||
| html( | ||
| '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">', | ||
| 'Cr\u00e8me' | ||
| ), | ||
| 'latin1' | ||
| ) | ||
| expect(decodePage(declared, 'text/html')).toContain('Crème') | ||
| }) | ||
|
|
||
| it('ignores a charset declared inside a comment', () => { | ||
| const body = Buffer.from( | ||
| html('<!-- <meta charset="windows-1252"> --><meta charset="utf-8">', 'Crème'), | ||
| 'utf8' | ||
| ) | ||
| expect(decodePage(body, 'text/html')).toContain('Crème') | ||
| }) | ||
| }) | ||
|
|
||
| describe('X-Robots-Tag', () => { | ||
| it('honors an unqualified noindex after another crawler’s directive in a repeated header', () => { | ||
| expect(robotsHeaderNoindex('otherbot: noindex, noindex')).toBe(true) | ||
| expect(robotsHeaderNoindex('otherbot: noindex')).toBe(false) | ||
| }) | ||
| }) |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.