Skip to content

Commit 22951d9

Browse files
dsarnoclaude
andauthored
fix: catch ArgumentException from Path.IsPathRooted in IsLocalServerPath (#746)
Path.IsPathRooted throws ArgumentException when the package source is a remote URL containing characters illegal in file paths. Catch the exception and return false since remote URLs are not local paths. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a88e9e2 commit 22951d9

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

MCPForUnity/Editor/Helpers/AssetPathUtility.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,18 @@ public static bool IsLocalServerPath()
448448
return false;
449449

450450
// Check for file:// protocol or absolute local path
451-
return fromUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase) ||
452-
System.IO.Path.IsPathRooted(fromUrl);
451+
if (fromUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
452+
return true;
453+
454+
try
455+
{
456+
return System.IO.Path.IsPathRooted(fromUrl);
457+
}
458+
catch (System.ArgumentException)
459+
{
460+
// fromUrl contains characters illegal in paths (e.g. a remote URL)
461+
return false;
462+
}
453463
}
454464

455465
/// <summary>

0 commit comments

Comments
 (0)