From 2de596017c89ce4b93f0efe045c6b6e9244a0445 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Thu, 21 Sep 2017 14:26:41 +0100
Subject: [PATCH] FIddle with display names & fix links

---
 GalleryShare/GalleryShare.csproj                    |  2 +-
 GalleryShare/RequestRouter/RouteDirectoryListing.cs | 10 ++++++----
 GalleryShare/packages.config                        |  2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/GalleryShare/GalleryShare.csproj b/GalleryShare/GalleryShare.csproj
index a695332..5c302ca 100644
--- a/GalleryShare/GalleryShare.csproj
+++ b/GalleryShare/GalleryShare.csproj
@@ -1,6 +1,6 @@
 ﻿<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props') AND '$(OS)' == 'Windows_NT'" />
+  <Import Project="..\packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.3.2\build\Microsoft.Net.Compilers.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
diff --git a/GalleryShare/RequestRouter/RouteDirectoryListing.cs b/GalleryShare/RequestRouter/RouteDirectoryListing.cs
index a7ca9f9..0de98b1 100644
--- a/GalleryShare/RequestRouter/RouteDirectoryListing.cs
+++ b/GalleryShare/RequestRouter/RouteDirectoryListing.cs
@@ -63,8 +63,9 @@ namespace GalleryShare.RequestRouter
 				await xmlData.WriteStartElementAsync(null, "ListingEntry", null);
 				await xmlData.WriteAttributeStringAsync(null, "Type", null, "Directory");
 
-				await xmlData.WriteElementStringAsync(null, "Name", null, escapePath("/" + directoryName.Substring(parentServer.ServingDirectory.Length)));
-				await xmlData.WriteElementStringAsync(null, "DisplayName", null, "/" + directoryName.Substring(parentServer.ServingDirectory.Length));
+				string relativePath = directoryName.Substring(parentServer.ServingDirectory.Length);
+				await xmlData.WriteElementStringAsync(null, "Name", null, escapePath("/" + relativePath.TrimStart("/".ToCharArray())));
+				await xmlData.WriteElementStringAsync(null, "DisplayName", null, relativePath.Substring(relativePath.LastIndexOf("/") + 1).TrimStart("/".ToCharArray()));
 				await xmlData.WriteElementStringAsync(null, "ItemCount", null, Directory.GetFileSystemEntries(directoryName).Length.ToString());
 
 				await xmlData.WriteEndElementAsync();
@@ -74,8 +75,9 @@ namespace GalleryShare.RequestRouter
 				await xmlData.WriteStartElementAsync(null, "ListingEntry", null);
 				await xmlData.WriteAttributeStringAsync(null, "Type", null, "File");
 
-				await xmlData.WriteElementStringAsync(null, "Name", null, escapePath("/" + filename.Substring(parentServer.ServingDirectory.Length)));
-				await xmlData.WriteElementStringAsync(null, "DisplayName", null, "/" + filename.Substring(parentServer.ServingDirectory.Length));
+				string relativePath = filename.Substring(parentServer.ServingDirectory.Length);
+				await xmlData.WriteElementStringAsync(null, "Name", null, escapePath("/" + relativePath.TrimStart("/".ToCharArray())));
+				await xmlData.WriteElementStringAsync(null, "DisplayName", null, relativePath.Substring(relativePath.LastIndexOf("/") + 1).TrimStart("/".ToCharArray()));
 
 				await xmlData.WriteEndElementAsync();
 			}
diff --git a/GalleryShare/packages.config b/GalleryShare/packages.config
index 8e0194c..f5fd3ad 100644
--- a/GalleryShare/packages.config
+++ b/GalleryShare/packages.config
@@ -1,5 +1,5 @@
 ﻿<?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="Microsoft.Net.Compilers" version="1.3.2" targetFramework="net45" />
+  <package id="Microsoft.Net.Compilers" version="2.3.2" targetFramework="net45" developmentDependency="true" />
   <package id="MimeSharp" version="1.0.0" targetFramework="net45" />
 </packages>
\ No newline at end of file
