Merge pull request #1090 from Santarh/nullCheck

Add null check in StringExtension
This commit is contained in:
ousttrue
2021-07-02 15:41:48 +09:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -76,6 +76,11 @@ namespace UniGLTF
// https://docs.unity3d.com/Manual/BestPracticeUnderstandingPerformanceInUnity5.html
public static bool FastStartsWith(this string a, string b)
{
if (a == null || b == null)
{
return false;
}
var aLen = a.Length;
var bLen = b.Length;
if (aLen < bLen)
@@ -94,6 +99,11 @@ namespace UniGLTF
public static bool FastEndsWith(this string a, string b)
{
if (a == null || b == null)
{
return false;
}
var aLen = a.Length;
var bLen = b.Length;
if (aLen < bLen)

View File

@@ -68,7 +68,7 @@ namespace UniGLTF
}
else
{
return Path.GetExtension(uri).ToLower();
return Path.GetExtension(uri)?.ToLowerInvariant() ?? string.Empty;
}
}
}