Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetCanonicalPath()

unsafe void System.Uri.GetCanonicalPath ( ref System::Text::ValueStringBuilder dest,
UriFormat formatAs )
inlineprivate

Definition at line 3125 of file Uri.cs.

3126 {
3127 if (InFact(Flags.FirstSlashAbsent))
3128 {
3129 dest.Append('/');
3130 }
3132 {
3133 return;
3134 }
3135 int length = dest.Length;
3137 if (formatAs == UriFormat.UriEscaped)
3138 {
3139 if (InFact(Flags.ShouldBeCompressed))
3140 {
3142 if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical) && !IsImplicitFile)
3143 {
3144 fixed (char* pch = dest)
3145 {
3146 int end = dest.Length;
3147 UnescapeOnly(pch, length, ref end, '.', '/', _syntax.InFact(UriSyntaxFlags.ConvertPathSlashes) ? '\\' : '\uffff');
3148 dest.Length = end;
3149 }
3150 }
3151 }
3152 else if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped))
3153 {
3156 {
3157 char[] array = readOnlySpan.ToArray();
3160 }
3161 UriHelper.EscapeString(readOnlySpan.Slice(_info.Offset.Path, _info.Offset.Query - _info.Offset.Path), ref dest, !IsImplicitFile, '?', '#');
3162 }
3163 else
3164 {
3166 }
3167 }
3168 else
3169 {
3171 if (InFact(Flags.ShouldBeCompressed) && _syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical) && !IsImplicitFile)
3172 {
3173 fixed (char* pch2 = dest)
3174 {
3175 int end2 = dest.Length;
3176 UnescapeOnly(pch2, length, ref end2, '.', '/', _syntax.InFact(UriSyntaxFlags.ConvertPathSlashes) ? '\\' : '\uffff');
3177 dest.Length = end2;
3178 }
3179 }
3180 }
3181 int num = length + securedPathIndex;
3182 if (securedPathIndex != 0 && dest[num - 1] == '|')
3183 {
3184 dest[num - 1] = ':';
3185 }
3186 if (InFact(Flags.ShouldBeCompressed) && dest.Length - num > 0)
3187 {
3188 dest.Length = num + Compress(dest.RawChars.Slice(num, dest.Length - num), _syntax);
3189 if (dest[length] == '\\')
3190 {
3191 dest[length] = '/';
3192 }
3193 if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical))
3194 {
3197 valueStringBuilder.Append(dest.AsSpan(length, dest.Length - length));
3199 ReadOnlySpan<char> stringToEscape = MemoryMarshal.CreateReadOnlySpan(ref valueStringBuilder.GetPinnableReference(), valueStringBuilder.Length);
3200 UriHelper.EscapeString(stringToEscape, ref dest, !IsImplicitFile, '?', '#');
3201 length = dest.Length;
3202 valueStringBuilder.Dispose();
3203 }
3204 }
3205 if (formatAs == UriFormat.UriEscaped || !InFact(Flags.PathNotCanonical))
3206 {
3207 return;
3208 }
3210 switch (formatAs)
3211 {
3212 case (UriFormat)32767:
3213 unescapeMode = (InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape) | UnescapeMode.V1ToStringFlag;
3214 if (IsImplicitFile)
3215 {
3216 unescapeMode &= ~UnescapeMode.Unescape;
3217 }
3218 break;
3219 case UriFormat.Unescaped:
3220 unescapeMode = ((!IsImplicitFile) ? (UnescapeMode.Unescape | UnescapeMode.UnescapeAll) : UnescapeMode.CopyOnly);
3221 break;
3222 default:
3223 unescapeMode = (InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape);
3224 if (IsImplicitFile)
3225 {
3226 unescapeMode &= ~UnescapeMode.Unescape;
3227 }
3228 break;
3229 }
3230 if (unescapeMode != 0)
3231 {
3234 valueStringBuilder2.Append(dest.AsSpan(length, dest.Length - length));
3237 {
3238 UriHelper.UnescapeString(pStr, 0, valueStringBuilder2.Length, ref dest, '?', '#', '\uffff', unescapeMode, _syntax, isQuery: false);
3239 }
3240 valueStringBuilder2.Dispose();
3241 }
3242 }
bool InFact(UriSyntaxFlags flags)
Definition UriParser.cs:221
Offset Offset
Definition Uri.cs:81
UriParser _syntax
Definition Uri.cs:193
int SecuredPathIndex
Definition Uri.cs:222
bool NotAny(Flags flags)
Definition Uri.cs:606
static unsafe void UnescapeOnly(char *pch, int start, ref int end, char ch1, char ch2, char ch3)
Definition Uri.cs:3244
bool InFact(Flags flags)
Definition Uri.cs:611
string _string
Definition Uri.cs:189
UriInfo _info
Definition Uri.cs:197
bool IsImplicitFile
Definition Uri.cs:201
static void Compress(char[] dest, int start, ref int destLength, UriParser syntax)
Definition Uri.cs:3300
UriFormat
Definition UriFormat.cs:4
ushort Path
Definition Uri.cs:119
ushort Query
Definition Uri.cs:121

References System.Uri._info, System.Uri._string, System.Uri._syntax, System.array, System.Uri.Compress(), System.Runtime.Serialization.Dictionary, System.UriHelper.EscapeString(), System.Uri.InFact(), System.UriParser.InFact(), System.Uri.IsImplicitFile, System.length, System.Uri.NotAny(), System.Uri.UriInfo.Offset, System.Uri.Offset.Path, System.Uri.Offset.Query, System.Uri.SecuredPathIndex, System.Uri.UnescapeOnly(), and System.UriHelper.UnescapeString().

Referenced by System.Uri.ReCreateParts().