Skip to content

Commit

Permalink
fix handling query params
Browse files Browse the repository at this point in the history
* remove the question mark from query param signature
* make params optional
* fix bug in param parsing
  • Loading branch information
nataliapanferova committed Jun 10, 2016
1 parent 3e00e84 commit db73fff
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions AWSSignature4DynamicValue.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

function getLocation(href) {
var match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);
var match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(?:\?([^#]*|)(#.*|))?$/);
return match && {
protocol: match[1],
host: match[2],
Expand Down Expand Up @@ -38,12 +38,16 @@ function getParametersString(request, search) {
/* Create the canonicalized query string that you need later in this
* procedure:
*/
if (search === null || typeof search === "undefined") {
return ""
}

var params = []

/* The parameters can come from the GET URI ... */
var query = search.split('&')
query.forEach(function(params) {
var parts = params.split('=',2)
query.forEach(function(param) {
var parts = param.split('=',2)
if (parts.length === 2 && parts[0] !== 'Signature') {
params.push(parts)
}
Expand Down

0 comments on commit db73fff

Please sign in to comment.