Skip to content

Commit fd38149

Browse files
committed
Improve normalization algorithm
1 parent 643759e commit fd38149

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

interfaces/UriString.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,16 @@ public static function normalize(Stringable|string $uri): string
295295
$path = self::removeDotSegments($path);
296296
}
297297

298-
$path = Encoder::decodePath($path);
299-
if (null !== self::buildAuthority($components) && ('' === $path || null === $path)) {
298+
$path = Encoder::encodePath(Encoder::decodePath($path));
299+
if (null !== self::buildAuthority($components) && ('' === $path)) {
300300
$path = '/';
301301
}
302302

303303
$components['path'] = $path;
304-
$components['query'] = Encoder::decodeQuery($components['query']);
305-
$components['fragment'] = Encoder::decodeFragment($components['fragment']);
306-
$components['user'] = Encoder::decodeUnreservedCharacters($components['user']);
307-
$components['pass'] = Encoder::decodeUnreservedCharacters($components['pass']);
304+
$components['query'] = Encoder::encodeQueryOrFragment(Encoder::decodeQuery($components['query']));
305+
$components['fragment'] = Encoder::encodeQueryOrFragment(Encoder::decodeFragment($components['fragment']));
306+
$components['user'] = Encoder::encodeUser(Encoder::decodeUnreservedCharacters($components['user']));
307+
$components['pass'] = Encoder::encodePassword(Encoder::decodeUnreservedCharacters($components['pass']));
308308

309309
return self::build($components);
310310
}

0 commit comments

Comments
 (0)