Skip to content

Commit 592d402

Browse files
committed
Update http structured fields test suite
1 parent c223ebb commit 592d402

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"source": {
7878
"url": "https://github.com/httpwg/structured-field-tests.git",
7979
"type": "git",
80-
"reference": "mnot/display-string"
80+
"reference": "main"
8181
}
8282
}
8383
}

src/DisplayString.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,20 @@ public function decoded(): string
8080
public function encoded(): string
8181
{
8282
$value = $this->value;
83+
8384
$encodeMatches = static fn (array $matches): string => match (1) {
84-
preg_match('/[^A-Za-z\d_\-.~]/', rawurldecode($matches[0])) => rawurlencode($matches[0]),
85+
preg_match('/[^A-Za-z\d_\-.~]/', rawurldecode($matches[0])) => strtolower(rawurlencode($matches[0])),
8586
default => $matches[0],
8687
};
8788

88-
return strtolower(match (true) {
89+
return match (true) {
8990
'' === $value => $value,
9091
default => (string) preg_replace_callback(
9192
'/[^A-Za-z\d_\-.~\!\$&\'\(\)\*\+,;\=%\\\\:@\/? ]+|%(?![A-Fa-f\d]{2})/',
9293
$encodeMatches(...),
9394
$value
9495
),
95-
});
96+
};
9697
}
9798

9899
public function equals(mixed $other): bool

0 commit comments

Comments
 (0)