diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs index 1ec8fd1af28cb..694310874e95d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs @@ -228,11 +228,10 @@ private static string ReadXdgDirectory(string homeDir, string key, string fallba int endPos = line.IndexOf('"', pos); if (endPos <= pos) continue; - // Got we need. Now extract it. - string path = line.Substring(pos, endPos - pos); + // Got what we need. Now extract it. return relativeToHome ? - Path.Combine(homeDir, path) : - path; + Path.Join(homeDir, line.AsSpan(pos, endPos - pos)) : + line.Substring(pos, endPos - pos); } } }