MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / EncodeProblemUrlChars

Method EncodeProblemUrlChars

src/Squirrel/MarkdownSharp.cs:1655–1677  ·  view source on GitHub ↗

hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems

(string url)

Source from the content-addressed store, hash-verified

1653 /// hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems
1654 /// </summary>
1655 private string EncodeProblemUrlChars(string url)
1656 {
1657 if (!_encodeProblemUrlCharacters) return url;
1658
1659 var sb = new StringBuilder(url.Length);
1660 bool encode;
1661 char c;
1662
1663 for (int i = 0; i < url.Length; i++)
1664 {
1665 c = url[i];
1666 encode = Array.IndexOf(_problemUrlChars, c) != -1;
1667 if (encode && c == ':' && i < url.Length - 1)
1668 encode = !(url[i + 1] == '/') && !(url[i + 1] >= '0' && url[i + 1] <= '9');
1669
1670 if (encode)
1671 sb.Append("%" + String.Format("{0:x}", (byte)c));
1672 else
1673 sb.Append(c);
1674 }
1675
1676 return sb.ToString();
1677 }
1678
1679
1680 /// <summary>

Callers

nothing calls this directly

Calls 3

FormatMethod · 0.80
IndexOfMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected