Skip to content

Commit e802ac2

Browse files
authored
Merge pull request #716 from adobe/robots-empty-line
fix: adding newline at the end of robots.txt
2 parents 61945b5 + 2e8382d commit e802ac2

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/robots-pipe.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function generateRobots(state) {
8686
'Allow: /',
8787
'',
8888
`Sitemap: https://${prodHost}/sitemap.xml`,
89+
'',
8990
].join('\n');
9091
return new PipelineResponse(txt, {
9192
status: 200,

src/sitemap-pipe.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async function generateSitemap(state) {
5252
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">',
5353
...data.map((record) => loc(record)),
5454
'</urlset>',
55+
'',
5556
].join('\n');
5657
return new PipelineResponse(xml, {
5758
status: 200,

test/robots-pipe.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ describe('Robots Pipe Test', () => {
154154
assert.strictEqual(resp.body, `User-Agent: *
155155
Allow: /
156156
157-
Sitemap: https://www.example.com/sitemap.xml`);
157+
Sitemap: https://www.example.com/sitemap.xml
158+
`);
158159
});
159160

160161
it('renders robots from live with www.aem.live', async () => {
@@ -189,7 +190,8 @@ Sitemap: https://www.example.com/sitemap.xml`);
189190
assert.strictEqual(resp.body, `User-Agent: *
190191
Allow: /
191192
192-
Sitemap: https://www.aem.live/sitemap.xml`);
193+
Sitemap: https://www.aem.live/sitemap.xml
194+
`);
193195
});
194196

195197
it('handles pipeline errors', async () => {

test/sitemap-pipe.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ describe('Sitemap Pipe Test', () => {
166166
<loc>https://ref--repo--owner.hlx.page/test</loc>
167167
<lastmod>2023-12-21</lastmod>
168168
</url>
169-
</urlset>`);
169+
</urlset>
170+
`);
170171
});
171172

172173
it('renders sitemap from preview with preview host', async () => {
@@ -202,7 +203,8 @@ describe('Sitemap Pipe Test', () => {
202203
<loc>https://ref--repo--owner.my.page/test</loc>
203204
<lastmod>2023-12-21</lastmod>
204205
</url>
205-
</urlset>`);
206+
</urlset>
207+
`);
206208
});
207209

208210
it('renders sitemap from live with prod CDN', async () => {
@@ -239,7 +241,8 @@ describe('Sitemap Pipe Test', () => {
239241
<loc>https://www.adobe.com/test</loc>
240242
<lastmod>2023-12-21</lastmod>
241243
</url>
242-
</urlset>`);
244+
</urlset>
245+
`);
243246
});
244247

245248
it('renders sitemap from live with live host', async () => {
@@ -276,7 +279,8 @@ describe('Sitemap Pipe Test', () => {
276279
<loc>https://ref--repo--owner.my.live/test</loc>
277280
<lastmod>2023-12-21</lastmod>
278281
</url>
279-
</urlset>`);
282+
</urlset>
283+
`);
280284
});
281285

282286
it('renders sitemap from live with fallback origin', async () => {
@@ -306,7 +310,8 @@ describe('Sitemap Pipe Test', () => {
306310
<loc>https://ref--repo--owner.hlx.live/test</loc>
307311
<lastmod>2023-12-21</lastmod>
308312
</url>
309-
</urlset>`);
313+
</urlset>
314+
`);
310315
});
311316

312317
it('handles pipeline errors', async () => {

0 commit comments

Comments
 (0)