public static string UrlCombine(params string[] paths) { var prefix = NormalizeUrlSlash(paths[0].Substring(0, 1)); var suffix = NormalizeUrlSlash(paths[paths.Length - 1].Substring(paths.Length - 1, 1)); for (var i = 0; i < paths.Length; i++) { if (paths[i].StartsWith(_back) || paths[i].StartsWith(_fwd)) { paths[i] = paths[i].Substring(1); } if (paths[i].EndsWith(_back) || paths[i].EndsWith(_fwd)) { paths[i] = paths[i].Substring(0, paths[i].Length - 1); } } var result = prefix + string.Join(_fwd, paths) + suffix; return result; static string NormalizeUrlSlash(string input) { if (input == _back) { input = _fwd; } else if (input != _fwd) { input = string.Empty; } return input; } }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.