Skip to content

Commit

Permalink
Merge pull request #23 from peter-gribanov/index_host
Browse files Browse the repository at this point in the history
Use host in RenderIndexFileStream
  • Loading branch information
peter-gribanov authored Aug 8, 2019
2 parents d0da3aa + 3da9965 commit 573b646
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Stream/RenderIndexFileStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(SitemapIndexRender $render, FileStream $substream, $
{
$this->render = $render;
$this->substream = $substream;
$this->host = $host;
$this->host = rtrim($host, '/');
$this->filename = $filename;
$this->state = new StreamState();
}
Expand Down Expand Up @@ -172,7 +172,7 @@ private function addSubStreamFileToIndex()
throw FileAccessException::failedOverwrite($filename, $new_filename);
}

fwrite($this->handle, $this->render->sitemap($indexed_filename, $last_mod));
fwrite($this->handle, $this->render->sitemap($this->host.'/'.$indexed_filename, $last_mod));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Stream/RenderIndexFileStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function initStream($subfilename = 'sitemap.xml')
$this->stream = new RenderIndexFileStream(
$this->render,
$this->substream,
'http://example.com',
'http://example.com/',
$this->filename
);
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public function testPush($subfilename, $indexed_filename)
$last_mod = (new \DateTimeImmutable())->setTimestamp($time);

$this->expected_content = $this->render->start().
$this->render->sitemap($indexed_filename, $last_mod).
$this->render->sitemap('http://example.com/'.$indexed_filename, $last_mod).
$this->render->end();

$this->assertFileExists($this->filename);
Expand Down

0 comments on commit 573b646

Please sign in to comment.