peterpostmann / resolve_uri
Resolves relative urls, like a browser would
1.0.0
2017-11-17 15:53 UTC
Requires
- peterpostmann/fileuri: ^1.0.0
- peterpostmann/parse_uri: ^1.0.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-11-10 05:08:57 UTC
README
Resolves relative urls, like a browser would.
This function returns a new URI based on base path (RFC3986 URL, URN, Windows path, relative path or file) and a new path.
Install
Via Composer
composer require peterpostmann/resolve_uri
If you dont want to use composer copy the resolve_uri.php
file and from [peterpostmann\php-parse_uri][2] the parse_uri.php
file and include it into your project.
Usage
use function peterpostmann\uri\resolve_uri; string resolve_uri ( string basePath, string newPath)
Example
parse URIs
use function peterpostmann\uri\resolve_uri; echo resolve_uri('http://a/b/c/d;p?q#x', 'x')."\n"; echo resolve_uri('C:\path\file1.ext', 'file2.ext')."\n"; echo resolve_uri('file://smb/path/to/file', '/new/path/x.ext')."\n";
The above example will output:
http://a/b/c/x C:\path\file2.ext file://smb/new/path/x.ext
License
The MIT License (MIT). Please see License File for more information.