Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fluffy-critter/php-urljoin
A library function for joining a base URL and a target URL into a an absolute URL
https://github.com/fluffy-critter/php-urljoin
php php-urljoin url-parsing
Last synced: 24 days ago
JSON representation
A library function for joining a base URL and a target URL into a an absolute URL
- Host: GitHub
- URL: https://github.com/fluffy-critter/php-urljoin
- Owner: fluffy-critter
- License: mit
- Created: 2016-10-15T01:56:26.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T23:23:14.000Z (4 months ago)
- Last Synced: 2024-11-08T07:45:11.550Z (about 2 months ago)
- Topics: php, php-urljoin, url-parsing
- Language: PHP
- Size: 30.3 KB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-urljoin
A PHP library function for joining a base URL and a potentially-relative target URL into an absolute URLWhy isn't this in the PHP standard library? WHO KNOWS.
Installation:
* Direct install: just pull `src/urljoin.php` into your project
* [Composer](https://packagist.org/packages/busybee/urljoin): `composer require busybee/urljoin`usage:
urljoin($base_url, $other_url);
See tests.php for test suite, as well as expected inputs and outputs. (Doing
this correctly is *way* more complicated thing than you'd think!) This
implementation strives for accuracy and, in cases of ambiguity (such as `../`
stack underflow and empty path components), defers to Python's standard library
behavior (as implemented by `urlparse.urljoin`).Other things that you might know this as:
* Relative path concatenation
* A function for converting a relative path to an absolute URL given a base URL
* `rel2abs` and `relativeToAbsolute` (common names for this sort of function)