@@ -27,24 +27,23 @@ module.exports = function (source, options) {
2727
2828 // Construct query string
2929 const qs = source . queryObj
30- const queryCount = Object . keys ( qs ) . length
30+ const queryKeys = Object . keys ( qs )
31+ const queryCount = queryKeys . length
3132 delete source . queryObj . key
3233
33- if ( source . queryString . length === 1 ) {
34- code . push ( 'queryString <- list(%s = "%s")' , Object . keys ( qs ) , Object . values ( qs ) . toString ( ) )
34+ if ( queryCount === 1 ) {
35+ code . push ( 'queryString <- list(%s = "%s")' , queryKeys , Object . values ( qs ) . toString ( ) )
3536 . blank ( )
36- } else if ( source . queryString . length > 1 ) {
37- let count = 1
38-
37+ } else if ( queryCount > 1 ) {
3938 code . push ( 'queryString <- list(' )
4039
41- for ( const query in qs ) {
42- if ( count ++ !== queryCount - 1 ) {
43- code . push ( ' %s = "%s",' , query , qs [ query ] . toString ( ) )
40+ queryKeys . forEach ( ( queryKey , index ) => {
41+ if ( index !== queryCount - 1 ) {
42+ code . push ( ' %s = "%s",' , queryKey , qs [ queryKey ] . toString ( ) )
4443 } else {
45- code . push ( ' %s = "%s"' , query , qs [ query ] . toString ( ) )
44+ code . push ( ' %s = "%s"' , queryKey , qs [ queryKey ] . toString ( ) )
4645 }
47- }
46+ } )
4847
4948 code . push ( ')' )
5049 . blank ( )
0 commit comments