-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DomCrawler] Remove the query string and the anchor of the uri of a link #11194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
benja-M-1
commented
Jun 21, 2014
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | ~ |
License | MIT |
Doc PR | ~ |
@@ -129,7 +121,7 @@ public function getUri() | |||
|
|||
// absolute path | |||
if ('/' === $uri[0]) { | |||
return $baseUri.$uri; | |||
return $this->cleanUri($baseUri).$uri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be done before the preg_replace call a few lines above actually ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your comment I refactored a bit the code.
@fabpot do you want me to squash the first commit and the second in which I renamed the method? |
👍 |
|
||
// anchor or query string | ||
if ('#' === $uri[0] || '?' === $uri[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is wrong. In case the link is an anchored link, the query string should not be removed from the current URI, only the fragment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, this case is missing from the testsuite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum you are right. I didn't thought about this case. I will change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add a test covering the combination of query string and fragment for both types of links
* | ||
* @param $uri | ||
* | ||
* @return array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this returns a string
once the phpdoc is fixed, 👍 |
Thank you @benja-M-1. |
… uri of a link (benja-M-1) This PR was squashed before being merged into the 2.3 branch (closes #11194). Discussion ---------- [DomCrawler] Remove the query string and the anchor of the uri of a link | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- fe5d2d1 [DomCrawler] Remove the query string and the anchor of the uri of a link
This PR was merged into the 2.3 branch. Discussion ---------- [DomCrawler] Fix Link docblocks and formatting | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - re #11194 Commits ------- 5cbe13e [DomCrawler] Fix docblocks and formatting.