No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StringUtils.cs 802B

1234567891011121314151617181920212223242526
  1. using System.IO;
  2. using System.Runtime.CompilerServices;
  3. [assembly: InternalsVisibleTo("Unity.VSCode.EditorTests")]
  4. namespace VSCodeEditor
  5. {
  6. internal static class StringUtils
  7. {
  8. private const char WinSeparator = '\\';
  9. private const char UnixSeparator = '/';
  10. public static string NormalizePath(this string path)
  11. {
  12. if (string.IsNullOrEmpty(path))
  13. return path;
  14. if (Path.DirectorySeparatorChar == WinSeparator)
  15. path = path.Replace(UnixSeparator, WinSeparator);
  16. if (Path.DirectorySeparatorChar == UnixSeparator)
  17. path = path.Replace(WinSeparator, UnixSeparator);
  18. return path.Replace(string.Concat(WinSeparator, WinSeparator), WinSeparator.ToString());
  19. }
  20. }
  21. }