(input: string, finalize: boolean)
| 52 | } |
| 53 | |
| 54 | private processBuffer(input: string, finalize: boolean): void { |
| 55 | this.buffer += input; |
| 56 | |
| 57 | if (finalize || this.buffer.includes('\n')) { |
| 58 | const parts = this.buffer |
| 59 | .split('\n') |
| 60 | .map((part) => part.trim()) |
| 61 | .filter((part) => part.length > 0); |
| 62 | |
| 63 | if (finalize) { |
| 64 | for (const url of parts) { |
| 65 | this.push({ type: 'url', loc: url } satisfies SitemapItem); |
| 66 | } |
| 67 | |
| 68 | this.buffer = ''; |
| 69 | } else if (parts.length > 0) { |
| 70 | for (const url of parts.slice(0, -1)) { |
| 71 | this.push({ type: 'url', loc: url } satisfies SitemapItem); |
| 72 | } |
| 73 | |
| 74 | this.buffer = parts.at(-1)!; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | class SitemapXmlParser extends Transform { |
no test coverage detected