<div dir="ltr"><div>I just found an issue with my D1 => D2 migration that broke the Perl Maven site.</div><div>I think I managed to fix it but I'd like to clarify this:</div><div><br></div><div>I used to have a route handler like this:</div><div>
<p class=""><span class="">get </span><span class="">qr{/pro/</span><span class="">(.*)</span><span class="">}</span><span class=""> => </span><span class="">sub </span><span class="">{</span></p>
<p class=""><span class=""> </span><span class="">my</span><span class=""> (</span><span class="">$path</span><span class="">) = splat;</span></p>
<p class=""><span class=""> </span><span class="">return</span><span class=""> </span><span class="">$path</span><span class="">;</span></p>
<p class=""><span class="">};</span></p></div><div>In D1 this was matching only routes that started with /pro</div><div>As if there was an implicit ^ at the beginning of the route.</div><div><br></div><div>Now, in D2, it will match anywhere so it started to match URLs such as</div><div>/media/pro/file</div><div><br></div><div>I could fix this by adding an explicit caret to the beginning of the regex:</div><div><br></div><div><div><p class=""><span class="">get </span><span class="">qr{^/pro/</span><span class="">(.*)</span><span class="">}</span><span class=""> => </span><span class="">sub </span><span class="">{</span></p><p class=""><span class=""> </span><span class="">my</span><span class=""> (</span><span class="">$path</span><span class="">) = splat;</span></p><p class=""><span class=""> </span><span class="">return</span><span class=""> </span><span class="">$path</span><span class="">;</span></p><p class=""><span class="">};</span></p><p class="">Please confirm if this is really the case or if I just had some other issues?</p></div></div><div><span class="">I think this should be added to the migration document with the recommended solution.</span></div><div><span class=""><br></span></div><div>Could I have solved this with the "prefix" keyword? How? Would that be better?<br></div><div><br></div><div>regards</div><div> Gabor</div><div><br></div><div><br></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Gabor Szabo <a href="http://szabgab.com/" target="_blank">http://szabgab.com/</a><br>Perl Maven <a href="http://perlmaven.com/" target="_blank">http://perlmaven.com/</a><br>Perl Weekly <a href="http://perlweekly.com/" target="_blank">http://perlweekly.com/</a><br>Phone: +972-54-4624648</div></div>
</div>