Laravel PHPunit - issue with adding slash - laravel-5

url() seems to be adding an extra slash, what is going on here?
dump(url()->previous());
if(url()->previous() == route('register')) dump('was register');
dump('--');
Outputs
"http://domain.com.au:8000//register"
"--"
I am expecting the previous url to match the route. However this is not the case. So where is this extra slash coming from?
Maybe related to this SO question
This issue only presents itself while using phpunit

Keep adding slashes
->seePageIs('//register');

Related

Are static URL paths valid after parameters in labstack/echo

I’m chasing an odd pattern matching issue in labstack/echo and would like your thoughts.
Would the route
/first/:parameter/second
match the url
http://hostname/first or http://hostname/first/ ?
What about
/first/:parameter1/second/:parameter2/:parameter3/third/ ?
To my eye, they should not match the simple urls, but they appear to be. Is that desired behavior? Has anyone followed a parameter with a static in the url pattern?
In Echo your routes need to be in an order to not match. See the Routing Guide here and look for Path Matching Order
https://echo.labstack.com/guide/routing
Switch around your routes so your /first/:parameter/second doesn't match /first/:parameter1/second/:parameter2/:parameter3/third/

IIS7.5 URL Rewrite, with or without trailing slash

I'm using IIS7.5 and have a rule for rewriting a URL...
The rule is:
^trade/new_products/page([^/]+)/?.*$
But, this is only working when I don't include a slash - e.g.
http://www.website.com/trade/new_products/page1
I'd like it to also work with
http://www.toppstiles.co.uk/trade/new_products/page1/
Can I do this or do I need a separate rule?
This group ([^/]+) is catching everything but slash. If your page is only numeric you can try this one:
^trade/new_products/page([0-9]+)/?.*$
If not, you can use the non greedy modifier on the multiplier(+?):
^trade/new_products/page([^/]+?)/?.*$
Sorry - the rule was working as expected - it was another issue that was causing my problem!

url rewrite pattern generates to many redirects

I have been struggling with the same issue for a while now and I could not find an good answer yet. I'm using rack-rewrite to add some url rewrite rules to my app's middleware stack.
I have the following rule:
r301 %r{^/([^(docs|help|legal|login|account|apps)])(.+)/$}, '$1'
Which is not working properly or as I would expect it. I have tried one of my previous question's answer, but neither that works, it actually generates an event more weird behaviour (it redirects to an url without the domain name, just to the path).
What I am trying to do is:
if user requests http://example.com/ or http://example.com/random-path/ I need the rewrite rule to strip the slash, thus the examples would become http://example.com respectively http://example.com/random-path;
if the requested paths matches any of the paths in the list docs|help|legal|login|account|apps, do not strip the slash at the end of the path if exists, but add a slash if it's not there
I tried with two rules, one that ignores the listed paths above and strips slashes and one that adds the slash if it hits something from the list and the slash after the path is not there:
r301 %r{^/([^(docs|help|legal|login|account|apps)])(.+)/$}, '/$1'
r301 %r{^/([(docs|help|legal|login|account|apps)])(.+)/$}, '/$1/'
How could I write a rule that would do that, or two rules, because what I tried it did not work?
You can do that like so:
r301 %r{^/((?!docs|help|legal|login|account|apps).+)/$}, '/$1'
r301 %r{^/((?=docs|help|legal|login|account|apps).+[^/])$}, '/$1/'
example 1
example 2
and some documentation on lookahead and lookbehind
EDIT: stray parentheses.

isapi rewrite 3 changing # character into a %23 in browser

All,
Trying to redirect too a URL like below:
http://domain/something/index.html#some/more/stuff.html
only problem here is that the # is getting changed into a %23 and it does not fine this URL.
Am i supposed to treat this differently?
Thanks in advance
Citty
Was missing the no escape tag [NE]
citty

url-rewriting and rss feed (feedburner) issue

I am using below rule to read the URL like
URL:
http://www.example.com/blog/sampe-post-title/10004/
RULE:
RewriteRule (.*)/(.*)/([0-9]+)/$ $1/details.asp?mod_id=$3 [NS,I]
Everything was fine untill I discovered that links coming via feedburner are not working anymore. Because feedburner adds some extra parameter to URL for stats/tracking etc.
For example www.example.com/blog/sampe-post-title/10004/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed:+somesite+(my+feed)
My rewrite URL doesn't recognizes the above URL anymore. Any idea how to deal with it?
Try adding a rule for the feedburner URLs:
RewriteRule (.*)/(.*)/([0-9]+)/\?(.*)$ $1/details.asp?mod_id=$3&$4 [NS,I]
I added an extra RegEx group at the end to capture everything after the question mark and place it after mod_id. You could probably combine this with your other URL if you only wanted to have one rule for some reason, but you might as well just have two.
Try the QSA flag to get the original requested URL query automatically appended to the new one.
I managed to figure out the answer on my own: just replace the ending $ with .* That's it!
Here is the modified rule:
RewriteRule (.*)/(.*)/([0-9]+)/.* $1/details.asp?mod_id=$3 [NS,I]

Resources