-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use URLSearchParams for paramsObject and update corresponding tests t…
…o expect URLSearchParams objects Add utility methods for URLSearchParams URLSearchParams don't have notions of equality defined in the spec, so we go through iterating over all entries checking for equality for testing purposes; Chrome (v60) currently doesn't support constructing URLSearchParams from objects, so add utility method to convert objects into arrays of pairs Update tests to expect URLSearchParams for search query Tests that would normally expect objects for search params now expect URLSearchParams; add test for multiple values same key Implement URLSearchParams for search query Most of the work is offloaded to URLSearchParams re: parsing and serializing, this change is predominatly updating the type of paramsObject Add polyfill for URLSearchParams I.E. does not implement URLSearchParams
- Loading branch information
Cole Hansen
committed
Jul 27, 2017
1 parent
faaa959
commit e0976e3
Showing
4 changed files
with
119 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script> | ||
var URLSearchParamsUtil = (function() { | ||
return { | ||
equal: function(url1, url2) { | ||
var url1Array = Array.from(url1.entries()), | ||
url2Array = Array.from(url2.entries()); | ||
if (url1Array.length !== url2Array.length) { | ||
return false; | ||
} | ||
for (var i = 0; i < url1Array.length; ++i) { | ||
if (url1Array[i][0] !== url2Array[i][0] || | ||
url1Array[i][1] !== url2Array[i][1]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}, | ||
objectToArray: function(obj) { | ||
var arr = []; | ||
for (var prop in obj) { | ||
arr.push([prop, obj[prop]]); | ||
} | ||
return arr; | ||
} | ||
} | ||
})(); | ||
</script> |