Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Util
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv8601/src/Spring/Spring.Web/Util
Modified Files:
WebUtils.cs
Log Message:
fixed SPRNET-762
Index: WebUtils.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Util/WebUtils.cs,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** WebUtils.cs 28 Nov 2007 23:26:00 -0000 1.31
--- WebUtils.cs 19 Mar 2008 18:05:07 -0000 1.32
***************
*** 147,151 ****
/// <p>
/// If relative path starts with '/' (forward slash), no concatenation will occur
! /// and it will be assumes that the relative path specified is indeed the absolute path
/// and will be returned verbatim.</p>
/// <p>
--- 147,151 ----
/// <p>
/// If relative path starts with '/' (forward slash), no concatenation will occur
! /// and it will be assumed that the relative path specified is indeed the absolute path
/// and will be returned verbatim.</p>
/// <p>
***************
*** 210,213 ****
--- 210,246 ----
return combinedPath;
}
+
+ /// <summary>
+ /// Gets the application-relative virtual path portion of the given absolute URL.
+ /// </summary>
+ /// <param name="url">the absolute url</param>
+ /// <returns>the url relative to the current application's virtual path</returns>
+ public static string GetAppRelativePath(string url)
+ {
+ string appPath = VirtualEnvironment.ApplicationVirtualPath;
+ return GetRelativePath(appPath, url);
+ }
+
+ /// <summary>
+ /// Gets the virtual path portion of the given absolute URL
+ /// relative to the given base path.
+ /// </summary>
+ /// <remarks>
+ /// Base path comparison is done case insensitive.
+ /// </remarks>
+ /// <param name="basePath">the absolute base path</param>
+ /// <param name="url">the absolute url</param>
+ /// <returns>the url relative to the given basePath</returns>
+ public static string GetRelativePath(string basePath, string url)
+ {
+ // strip application path from url
+ string appPath = basePath.TrimEnd('/');
+ string appRelativeVirtualPath = url;
+ if (appRelativeVirtualPath.ToLower().StartsWith(appPath.ToLower()))
+ {
+ appRelativeVirtualPath = appRelativeVirtualPath.Substring(appPath.Length);
+ }
+ return appRelativeVirtualPath;
+ }
}
}
\ No newline at end of file
|