Skip to content

Commit

Permalink
better url_simplify() (#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann committed Apr 1, 2020
1 parent ce6f5f0 commit 98707e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/zoteroTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testDropSomeURLEquivs5() {
public function testSimpleIEEE() {
$url = "http://ieeexplore.ieee.org/arnumber=123456789";
$url = url_simplify($url);
$this->assertSame('http://ieeexplore.ieee.org/123456789/', $url);
$this->assertSame('http:/ieeexplore.ieee.org/123456789/', $url);
}

public function testIEEEdoi() {
Expand Down
4 changes: 2 additions & 2 deletions zotero.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ function url_simplify($url) {
$url = 'https://ieeexplore.ieee.org/document/' . $matches[1];
}
$url = $url . '/';
$url = str_replace(['/abstract/', '/full/', '/full+pdf/', '/pdf/', '/document/', '/html/', '/html+pdf/', '/abs/', '/epdf/', '/doi/', '/xprint/', '/print/', '.short/', '.long/'],
['/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/'], $url);
$url = str_replace(['/abstract/', '/full/', '/full+pdf/', '/pdf/', '/document/', '/html/', '/html+pdf/', '/abs/', '/epdf/', '/doi/', '/xprint/', '/print/', '.short', '.long', '.abstract', '.full', '///', '//'],
['/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/'], $url);
$ul = substr($url, 0, -1); // Remove the ending slash we added
$url = strtok($url, '?#');
$url = str_ireplace('https', 'http', $url);
Expand Down

0 comments on commit 98707e0

Please sign in to comment.