Skip to content

Commit

Permalink
Merge pull request #375 from tdt/development
Browse files Browse the repository at this point in the history
No empty query string parameters are allowed
  • Loading branch information
coreation committed Jan 20, 2016
2 parents 0c0c5ea + b3b39b3 commit 715492c
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions app/Tdt/Core/Formatters/HTMLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,39 @@ public static function getBody($dataObj)
$query_string = '';

if (!empty($_GET)) {
$query_string = '?' . http_build_query(\Input::all());
$get_params = \Input::get();

foreach ($get_params as $param => $val) {
if (!empty($val)) {
$query_string .= "&$param=$val";
}
}

if (!empty($query_string)) {
$query_string = trim($query_string, '&');
$query_string = '?' . $query_string;
}
}

// Links to pages
$prev_link = '';
$next_link = '';

if (!empty($dataObj->paging)) {
$input_array = array_except(\Input::all(), array('limit', 'offset'));
$input_array = array_except(\Input::get(), array('limit', 'offset'));

$query_string = '';
if (!empty($input_array)) {
$query_string = '&' . http_build_query($input_array);
foreach ($get_params as $param => $val) {
if (!empty($val)) {
$query_string .= "&$param=$val";
}
}

if (!empty($query_string)) {
$query_string = trim($query_string, '&');
$query_string = '?' . $query_string;
}
}

if (!empty($dataObj->paging['previous'])) {
Expand Down

0 comments on commit 715492c

Please sign in to comment.