Skip to content

Commit

Permalink
😭 Downgraded to NETSTANDARD12 and remove trailing slash. (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
PureKrome authored Sep 24, 2020
1 parent 81d52a3 commit 5720402
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.100",
"rollForward": "latestMinor"
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion src/SimpleSitemap/SimpleSitemap.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard1.2;netstandard2.0</TargetFrameworks>
<PackageId>SimpleSitemap</PackageId>
<Authors>Justin Adler</Authors>
<Company>World Domination Technologies Pty. Ltd.</Company>
Expand Down
14 changes: 11 additions & 3 deletions src/SimpleSitemap/SitemapService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ namespace SimpleSiteMap
public class SitemapService
{
private const string SitemapsNamespace = "http://www.sitemaps.org/schemas/sitemap/0.9";
#if NETSTANDARD1_2
private static readonly string ByteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble(), 0, Encoding.UTF8.GetPreamble().Length);
#else
private static readonly string ByteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());

#endif
/// <summary>
/// Creates a sitemap for the given collection.
/// </summary>
Expand Down Expand Up @@ -89,7 +92,7 @@ XElement GenerateLocXElement(SitemapNode sitemapNode, int page, bool appendPageQ

if (appendPageQueryParam)
{
uriString = $"{uriString}/?page={page}";
uriString = $"{uriString}?page={page}";
}

return new XElement(xmlns + "loc", uriString);
Expand Down Expand Up @@ -152,7 +155,12 @@ private static string ConvertXElementToString(XElement xElement)
xElement.Save(writer);
}

xmlResult = Encoding.UTF8.GetString(memoryStream.ToArray());
var array = memoryStream.ToArray();
#if NETSTANDARD1_2
xmlResult = Encoding.UTF8.GetString(array, 0, array.Length);
#else
xmlResult = Encoding.UTF8.GetString(array);
#endif
}

if (!string.IsNullOrWhiteSpace(xmlResult) &&
Expand Down
20 changes: 10 additions & 10 deletions tests/SimpleSiteMap.Tests/Result Data/SitemapWith10Items.xml
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=1</loc>
<loc>http://www.foo.com/sitemap/foos?page=1</loc>
<lastmod>2014-11-21T18:58:00+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=2</loc>
<loc>http://www.foo.com/sitemap/foos?page=2</loc>
<lastmod>2014-11-21T18:57:50+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=3</loc>
<loc>http://www.foo.com/sitemap/foos?page=3</loc>
<lastmod>2014-11-21T18:57:40+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=4</loc>
<loc>http://www.foo.com/sitemap/foos?page=4</loc>
<lastmod>2014-11-21T18:57:30+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=5</loc>
<loc>http://www.foo.com/sitemap/foos?page=5</loc>
<lastmod>2014-11-21T18:57:20+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=6</loc>
<loc>http://www.foo.com/sitemap/foos?page=6</loc>
<lastmod>2014-11-21T18:57:10+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=7</loc>
<loc>http://www.foo.com/sitemap/foos?page=7</loc>
<lastmod>2014-11-21T18:57:00+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=8</loc>
<loc>http://www.foo.com/sitemap/foos?page=8</loc>
<lastmod>2014-11-21T18:56:50+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=9</loc>
<loc>http://www.foo.com/sitemap/foos?page=9</loc>
<lastmod>2014-11-21T18:56:40+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.foo.com/sitemap/foos/?page=10</loc>
<loc>http://www.foo.com/sitemap/foos?page=10</loc>
<lastmod>2014-11-21T18:56:30+00:00</lastmod>
</sitemap>
</sitemapindex>

0 comments on commit 5720402

Please sign in to comment.