forked from friendica/php-json-ld
Always remove last base segment when calculating relative urls.
This commit is contained in:
parent
4233353828
commit
b04f314afa
11
jsonld.php
11
jsonld.php
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHP implementation of the JSON-LD API.
|
* PHP implementation of the JSON-LD API.
|
||||||
* Version: 0.2.6
|
* Version: 0.2.7
|
||||||
*
|
*
|
||||||
* @author Dave Longley
|
* @author Dave Longley
|
||||||
*
|
*
|
||||||
|
@ -707,12 +707,9 @@ function jsonld_remove_base($base, $iri) {
|
||||||
// use '../' for each non-matching base segment
|
// use '../' for each non-matching base segment
|
||||||
$rval = '';
|
$rval = '';
|
||||||
if(count($base_segments) > 0) {
|
if(count($base_segments) > 0) {
|
||||||
// don't count the last segment if it isn't a path (doesn't end in '/')
|
// don't count the last segment (if it ends with '/' last path doesn't
|
||||||
// don't count empty first segment, it means base began with '/'
|
// count and if it doesn't end with '/' it isn't a path)
|
||||||
if(substr($base['normalizedPath'], -1) !== '/' ||
|
array_pop($base_segments);
|
||||||
$base_segments[0] === '') {
|
|
||||||
array_pop($base_segments);
|
|
||||||
}
|
|
||||||
foreach($base_segments as $segment) {
|
foreach($base_segments as $segment) {
|
||||||
$rval .= '../';
|
$rval .= '../';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue