Skip to content

Commit aab15cc

Browse files
Update CSS scope computation
1 parent 9ae93d2 commit aab15cc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Razor/Microsoft.NET.Sdk.Razor/src/ComputeCssScope.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,19 @@ private string GenerateScope(string targetName, string relativePath)
5555
return builder.ToString();
5656
}
5757

58-
private string ToBase36(byte[] hash)
58+
private static string ToBase36(byte[] hash)
5959
{
60-
var builder = new StringBuilder();
61-
const string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
62-
var dividend = new BigInteger(hash.AsSpan().Slice(0,8).ToArray());
63-
while (dividend > 36)
60+
const string chars = "0123456789abcdefghijklmnopqrstuvwxyz";
61+
62+
var result = new char[10];
63+
var dividend = BigInteger.Abs(new BigInteger(hash.AsSpan().Slice(0, 9).ToArray()));
64+
for (var i = 0; i < 10; i++)
6465
{
6566
dividend = BigInteger.DivRem(dividend, 36, out var remainder);
66-
builder.Insert(0, chars[Math.Abs(((int)remainder))]);
67+
result[i] = chars[(int)remainder];
6768
}
68-
return builder.ToString();
69+
70+
return new string(result);
6971
}
7072
}
7173
}

0 commit comments

Comments
 (0)