[Mono-dev] HttpRequest.MapPath and UrlUtils.Combine code duplication

Andrew Skiba andrews at mainsoft.com
Sun Apr 9 11:08:07 EDT 2006


Hello.

I found code duplication, please review the patch to remove it.

If no one objects, I will commit.

Index: UrlUtils.cs
===================================================================
--- UrlUtils.cs	(revision 59261)
+++ UrlUtils.cs	(working copy)
@@ -101,7 +101,9 @@
 			if (rlength == 0)
 				return "";
 
-			relPath = relPath.Replace ("\\", "/");
+			if (System.IO.Path.DirectorySeparatorChar !=
'/')
+				relPath = relPath.Replace
(System.IO.Path.DirectorySeparatorChar, '/');
+
 			if (IsRooted (relPath))
 				return Canonic (relPath);
 
Index: HttpRequest.cs
===================================================================
--- HttpRequest.cs	(revision 59261)
+++ HttpRequest.cs	(working copy)
@@ -1163,17 +1163,10 @@
  			if
(virtualPath.StartsWith(vmw.common.IAppDomainConfig.WAR_ROOT_SYMBOL))

  				return 	virtualPath;			
 #endif 
-			if (System.IO.Path.DirectorySeparatorChar !=
'/')
-				virtualPath = virtualPath.Replace
(System.IO.Path.DirectorySeparatorChar, '/');
-
-			if (UrlUtils.IsRooted (virtualPath))
-				virtualPath = UrlUtils.Canonic
(virtualPath);
-			else {
-				if (baseVirtualDir == null)
-					baseVirtualDir = RootVirtualDir;
-				virtualPath = UrlUtils.Combine
(baseVirtualDir, virtualPath);
-			}
+			if (baseVirtualDir == null)
+				baseVirtualDir = RootVirtualDir;
+			virtualPath = UrlUtils.Combine (baseVirtualDir,
virtualPath);

  			if (!allowCrossAppMapping){
 				if (!StrUtils.StartsWith (virtualPath,
RootVirtualDir, true))
 					throw new HttpException
("MapPath: Mapping across applications not allowed");



More information about the Mono-devel-list mailing list