Skip to content

Commit

Permalink
Merge pull request #22 from jeremykendall/fix/issue-20
Browse files Browse the repository at this point in the history
Updates parser to allow for more accurate URL parsing
  • Loading branch information
jwage committed Dec 24, 2013
2 parents 26d6a6f + 7dae0e0 commit 732eaec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"require": {
"php": ">=5.3.0",
"jeremykendall/php-domain-parser": "0.0.8"
"jeremykendall/php-domain-parser": "1.*"
}
}
10 changes: 9 additions & 1 deletion src/Purl/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ public function parseUrl($url)
$url = (string) $url;
}

$result = parse_url($url);
$result = false;

// If there's a single leading forward slash, use parse_url()
if (preg_match('#^\/{1}[^\/]#', $url) === 1) {
$result = parse_url($url);
} else {
// Otherwise use the PSL parser
$result = $this->pslParser->parseUrl($url)->toArray();
}

if ($result === false) {
throw new \InvalidArgumentException(sprintf('Invalid url %s', $url));
Expand Down
2 changes: 1 addition & 1 deletion src/Purl/ParserInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* This file is part of the Purl package, a project by Jonathan H. Wage.
*
* (c) 2013 Jonathan H. Wage
Expand Down

0 comments on commit 732eaec

Please sign in to comment.