MCPcopy
hub / github.com/apify/crawlee / onText

Method onText

packages/utils/src/internals/sitemap.ts:145–172  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

143 }
144
145 private onText(text: string) {
146 if (this.currentTag === 'loc') {
147 if (this.rootTagName === 'sitemapindex') {
148 this.push({ type: 'sitemapUrl', url: text.trim() } satisfies SitemapItem);
149 }
150
151 if (this.rootTagName === 'urlset') {
152 this.url ??= {};
153 this.url.loc = text.trim();
154 }
155 }
156
157 text = text.trim();
158
159 if (this.currentTag === 'lastmod') {
160 this.url.lastmod = new Date(text);
161 }
162
163 if (this.currentTag === 'priority') {
164 this.url.priority = Number(text);
165 }
166
167 if (this.currentTag === 'changefreq') {
168 if (['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'].includes(text)) {
169 this.url.changefreq = text as SitemapUrl['changefreq'];
170 }
171 }
172 }
173}
174
175export interface ParseSitemapOptions {

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected