docs: add url transformer implementation plan #1

Merged
keith merged 11 commits from feature/url-transformer-plan into main 2026-04-27 00:55:10 +00:00
2 changed files with 18 additions and 1 deletions
Showing only changes of commit e744754389 - Show all commits
+1 -1
View File
@@ -56,7 +56,7 @@ final class UrlTransformer {
$sources $sources
); );
return '~(?<![A-Za-z0-9.-])(?:' . implode( '|', $quoted ) . ')(?![A-Za-z0-9.-])~'; return '~(?<![A-Za-z0-9.-])(?:' . implode( '|', $quoted ) . ')(?![A-Za-z0-9.@-])~';
} }
private function toProtocolRelative( string $url ): string { private function toProtocolRelative( string $url ): string {
+17
View File
@@ -114,6 +114,23 @@ class UrlTransformerTest extends TestCase {
); );
} }
public function test_it_does_not_rewrite_userinfo_host_lookalikes(): void {
$transformer = new UrlTransformer();
$mappings = new UrlMappingCollection(
array(
new UrlMapping( 'https://example.test', 'https://staging.example.test' ),
)
);
self::assertSame(
'https://example.test@evil.test/path https://staging.example.test/path',
$transformer->transformString(
'https://example.test@evil.test/path https://example.test/path',
$mappings
)
);
}
public function test_it_prefers_more_specific_overlapping_mappings(): void { public function test_it_prefers_more_specific_overlapping_mappings(): void {
$transformer = new UrlTransformer(); $transformer = new UrlTransformer();
$mappings = new UrlMappingCollection( $mappings = new UrlMappingCollection(