diff --git a/global.json b/global.json index ed008b5..b5327d0 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "version": "3.1.100", - "rollForward": "latestMinor" + "rollForward": "latestFeature" } } diff --git a/src/SimpleSitemap/SimpleSitemap.csproj b/src/SimpleSitemap/SimpleSitemap.csproj index 99bbd89..d87cc80 100644 --- a/src/SimpleSitemap/SimpleSitemap.csproj +++ b/src/SimpleSitemap/SimpleSitemap.csproj @@ -1,7 +1,7 @@ - netstandard1.3;netstandard2.0 + netstandard1.2;netstandard2.0 SimpleSitemap Justin Adler World Domination Technologies Pty. Ltd. diff --git a/src/SimpleSitemap/SitemapService.cs b/src/SimpleSitemap/SitemapService.cs index b6c3a4f..ebfa72e 100644 --- a/src/SimpleSitemap/SitemapService.cs +++ b/src/SimpleSitemap/SitemapService.cs @@ -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 /// /// Creates a sitemap for the given collection. /// @@ -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); @@ -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) && diff --git a/tests/SimpleSiteMap.Tests/Result Data/SitemapWith10Items.xml b/tests/SimpleSiteMap.Tests/Result Data/SitemapWith10Items.xml index 96e8a3f..fcdfc61 100644 --- a/tests/SimpleSiteMap.Tests/Result Data/SitemapWith10Items.xml +++ b/tests/SimpleSiteMap.Tests/Result Data/SitemapWith10Items.xml @@ -1,43 +1,43 @@  - http://www.foo.com/sitemap/foos/?page=1 + http://www.foo.com/sitemap/foos?page=1 2014-11-21T18:58:00+00:00 - http://www.foo.com/sitemap/foos/?page=2 + http://www.foo.com/sitemap/foos?page=2 2014-11-21T18:57:50+00:00 - http://www.foo.com/sitemap/foos/?page=3 + http://www.foo.com/sitemap/foos?page=3 2014-11-21T18:57:40+00:00 - http://www.foo.com/sitemap/foos/?page=4 + http://www.foo.com/sitemap/foos?page=4 2014-11-21T18:57:30+00:00 - http://www.foo.com/sitemap/foos/?page=5 + http://www.foo.com/sitemap/foos?page=5 2014-11-21T18:57:20+00:00 - http://www.foo.com/sitemap/foos/?page=6 + http://www.foo.com/sitemap/foos?page=6 2014-11-21T18:57:10+00:00 - http://www.foo.com/sitemap/foos/?page=7 + http://www.foo.com/sitemap/foos?page=7 2014-11-21T18:57:00+00:00 - http://www.foo.com/sitemap/foos/?page=8 + http://www.foo.com/sitemap/foos?page=8 2014-11-21T18:56:50+00:00 - http://www.foo.com/sitemap/foos/?page=9 + http://www.foo.com/sitemap/foos?page=9 2014-11-21T18:56:40+00:00 - http://www.foo.com/sitemap/foos/?page=10 + http://www.foo.com/sitemap/foos?page=10 2014-11-21T18:56:30+00:00 \ No newline at end of file