Permalink
Browse files

Fixed a bug when ServerRelativeUrl is '/'

  • Loading branch information...
1 parent faa9715 commit d40973da7b8b4bcdd57edec361ce849c5728044b @kmees kmees committed Mar 7, 2013
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/IronSharePoint.Framework/Hives/SPDocumentHive.cs
@@ -7,6 +7,7 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
+using IronSharePoint.Framework.Util;
using Microsoft.SharePoint;
namespace IronSharePoint.Framework.Hives
@@ -16,8 +17,8 @@ namespace IronSharePoint.Framework.Hives
/// </summary>
public class SPDocumentHive : IHive
{
- private Guid _siteId;
- private string _hiveLibraryPath;
+ private readonly Guid _siteId;
+ private readonly string _hiveLibraryPath;
private string _webUrl;
private string _hiveLibraryUrl;
@@ -32,9 +33,14 @@ public IEnumerable<string> CachedFiles
public IEnumerable<string> CachedDirs
{
get { return _cachedDirs.AsEnumerable(); }
- }
+ }
+
+ public SPDocumentHive(Guid siteId)
+ : this(siteId, IronConstant.HiveLibraryPath)
+ {
+ }
- public SPDocumentHive(Guid siteId, string hiveLibraryPath = IronConstant.HiveLibraryPath)
+ public SPDocumentHive(Guid siteId, string hiveLibraryPath)
{
_siteId = siteId;
_hiveLibraryPath = hiveLibraryPath;
@@ -144,8 +150,8 @@ public void Reset()
foreach (SPListItem item in allItems)
{
var fileRef = item["FileRef"].ToString();
- var siteRelative = fileRef.Replace(lib.ParentWeb.ServerRelativeUrl, string.Empty).TrimStart('/');
- var hiveRelative = siteRelative.Replace(_hiveLibraryPath,string.Empty).TrimStart('/');
+ var siteRelative = fileRef.ReplaceFirst(lib.ParentWeb.ServerRelativeUrl, string.Empty).TrimStart('/');
+ var hiveRelative = siteRelative.ReplaceFirst(_hiveLibraryPath,string.Empty).TrimStart('/');
allFiles.Add(hiveRelative);
}

0 comments on commit d40973d

Please sign in to comment.