Skip to content

Commit

Permalink
Fix #27: Remove redundant code already available in extractLocalPartF…
Browse files Browse the repository at this point in the history
…romURI()
  • Loading branch information
samuell committed Aug 16, 2017
1 parent 39f7967 commit 73ee090
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions classes/parsers/RDFIO_URIToWikiTitleConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,30 +203,12 @@ function abbreviateParserNSPrefixes( $uri, $nsPrefixes ) {
}
}

/*
* Take care of some special cases:
*/
if ( $basepart === '' && $localpart === '' ) {
$uriParts = $this->splitURI( $uri );
$basepart = $uriParts[0];
$localpart = $uriParts[1];
}

if ( $localpart === '' ) {
$abbreviatedUri = $basepart;
} elseif ( substr( $basepart, 0, 4 ) === 'http' ) {
// If the abbreviation does not seem to have succeeded,
// fall back to use only the local part
$abbreviatedUri = $localpart;
} elseif ( substr( $basepart, -1 ) === ':' ) {
// Don't add another colon
$abbreviatedUri = $basepart . $localpart;
} elseif ( $basepart == false || $basepart == '' ) {
$abbreviatedUri = $localpart;
} else {
$abbreviatedUri = $basepart . ':' . $localpart;
// Make sure both basepart and localpart contains anything before proceeding
if ( $basepart === '' || $localpart === '' ) {
return '';
}

$abbreviatedUri = $basepart . ':' . $localpart;
return $abbreviatedUri;
}

Expand Down

0 comments on commit 73ee090

Please sign in to comment.