File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,9 @@ QueryString.prototype.parse = function (queryStr) {
6161 return obj ;
6262}
6363
64+ QueryString . prototype . extract = function ( url ) {
65+ return url . substring ( url . indexOf ( '?' ) + 1 ) ;
66+ }
67+
6468// Export the module
6569module . exports = new QueryString ( ) ;
Original file line number Diff line number Diff line change @@ -46,4 +46,25 @@ describe('query-stringifier', function () {
4646 expect ( parsed ) . to . have . property ( 'thing' , 'thung' ) ;
4747 } ) ;
4848 } ) ;
49+
50+ describe ( '#extract' , function ( ) {
51+ it ( 'exract the query string of the url' , function ( ) {
52+ var url = 'www.dummyurl.com?firstqueryparam=first&secondqueryparam=second' ;
53+ var result = qs . extract ( url ) ;
54+
55+ expect ( result ) . to . equal ( 'firstqueryparam=first&secondqueryparam=second' ) ;
56+ } ) ;
57+ } ) ;
58+
59+ describe ( '#extract/#parse' , function ( ) {
60+ it ( 'extract the query string of the url and parses it' , function ( ) {
61+ var url = 'www.dummyurl.com?firstqueryparam=first&secondqueryparam=second' ;
62+ var result = qs . parse ( qs . extract ( url ) ) ;
63+
64+ expect ( result ) . to . be . an ( 'object' ) ;
65+ expect ( result ) . to . have . property ( 'firstqueryparam' , 'first' ) ;
66+ expect ( result ) . to . have . property ( 'secondqueryparam' , 'second' ) ;
67+ } ) ;
68+ } ) ;
69+
4970} ) ;
You can’t perform that action at this time.
0 commit comments