Nasty little bug - easy fix - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Nasty little bug - easy fix (/showthread.php?tid=63505) |
Nasty little bug - easy fix - Nicolaus.Sommer - 11-07-2015 File: system/core/Config.php Line: 269 - $uri .= $suffix; + if (trim($uri) !== '') $uri .= $suffix; If $config['url_suffix'] is set to a value like $config['url_suffix'] = '.html' the home link will be generated as http://www.mydomain.com/.html The fix obove is solving the problem, however I hate to change the code in core, forcing me to keep track and check on the next release. RE: Nasty little bug - easy fix - Martin7483 - 11-07-2015 When having a suffix set in the config will not add the suffix when calling PHP Code: site_url(); // Result http://www.yourdomain.com It will add the suffix when passing an URI argument to this method PHP Code: site_url('some-kind-of-page'); // Result http://www.yourdomain.com/some-kind-of-page.html But when the argument is ?test=1234 PHP Code: site_url('?test=1234'); // Result http://www.yourdomain.com/.html?test=1234 But to fix this, you don't need to edit the core. You can override the site_url method by adding it to a MY_url_helper file. EDIT: I have added a site_url method to a MY_url_helper. It sets the correct URL when only passing an query string PHP Code: /** RE: Nasty little bug - easy fix - Nicolaus.Sommer - 11-07-2015 (11-07-2015, 08:41 AM)Martin7483 Wrote: When having a suffix set in the config will not add the suffix when calling As a matter of fact Code: site_url(' '); // Result http://www.yourdomain.com/ .html RE: Nasty little bug - easy fix - Martin7483 - 11-07-2015 Haha, did not test that scenario. But it's a quick fix. RE: Nasty little bug - easy fix - Martin7483 - 11-07-2015 I have updated the site_url method of MY_url_helper PHP Code: /** |