Skip to content

Commit 9af2361

Browse files
committed
Removed code that would strip format at the end of query params
This is incorrect and thus I have decided to strip out the offending code. It fixes chriskacerguis#442.
1 parent 30af149 commit 9af2361

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

application/libraries/REST_Controller.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -798,25 +798,12 @@ protected function _detect_output_format()
798798

799799
// Check if a file extension is used when no get arguments provided
800800
$matches = [];
801-
if (!$this->_get_args && preg_match($pattern, $this->uri->uri_string(), $matches))
801+
// Check if a file extension is used e.g. http://example.com/api/index.json?param1=param2
802+
if (preg_match($pattern, $this->uri->uri_string(), $matches))
802803
{
803804
return $matches[1];
804805
}
805806

806-
// Check if a file extension is used
807-
elseif ($this->_get_args && is_array(end($this->_get_args)) === FALSE && preg_match($pattern, end($this->_get_args), $matches))
808-
{
809-
// The key of the last argument
810-
$arg_keys = array_keys($this->_get_args);
811-
$last_key = end($arg_keys);
812-
813-
// Remove the extension from arguments too
814-
$this->_get_args[$last_key] = preg_replace($pattern, '', $this->_get_args[$last_key]);
815-
$this->_args[$last_key] = preg_replace($pattern, '', $this->_args[$last_key]);
816-
817-
return $matches[1];
818-
}
819-
820807
// Get the format
821808
$format = isset($this->_get_args['format']) ? strtolower($this->_get_args['format']) : NULL;
822809

0 commit comments

Comments
 (0)