Skip to content

parse_url() returns false on colon(:) followed by number inside path #17862

@RV7PR

Description

@RV7PR

Description

The following code:

<?php
print_r(parse_url('https://test.com/a/b/c:354/'));
print_r(parse_url('test.com/a/b/c:354/'));
print_r(parse_url('/a/b/c:354/'));

Resulted in this output:

Array
(
    [scheme] => https
    [host] => test.com
    [path] => /a/b/c:354/
)
Array
(
    [host] => test.com
    [port] => 354
    [path] => /a/b/c:354/
)

But I expected this output instead:

Array
(
    [scheme] => https
    [host] => test.com
    [path] => /a/b/c:354/
)
Array
(
    [host] => test.com
    [path] => /a/b/c:354/
)
Array
(
    [path] => /a/b/c:354/
)

PHP Version

PHP 8.4.4

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions