File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,12 @@ Usage: instantsearch({
108108 if ( this . urlSync ) {
109109 let syncWidget = urlSyncWidget ( this . urlSync ) ;
110110 this . _createURL = syncWidget . createURL . bind ( syncWidget ) ;
111+ this . _createAbsoluteURL = relative => this . _createURL ( relative , { absolute : true } ) ;
111112 this . _onHistoryChange = syncWidget . onHistoryChange . bind ( syncWidget ) ;
112113 this . widgets . push ( syncWidget ) ;
113114 } else {
114115 this . _createURL = defaultCreateURL ;
116+ this . _createAbsoluteURL = defaultCreateURL ;
115117 this . _onHistoryChange = function ( ) { } ;
116118 }
117119
@@ -160,7 +162,7 @@ Usage: instantsearch({
160162 results,
161163 state,
162164 helper,
163- createURL : this . _createURL
165+ createURL : this . _createAbsoluteURL
164166 } ) ;
165167 } , this ) ;
166168 this . emit ( 'render' ) ;
@@ -174,7 +176,7 @@ Usage: instantsearch({
174176 state,
175177 helper,
176178 templatesConfig,
177- createURL : this . _createURL ,
179+ createURL : this . _createAbsoluteURL ,
178180 onHistoryChange : _onHistoryChange
179181 } ) ;
180182 }
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ describe('InstantSearch lifecycle', () => {
195195 expect ( widget . render . calledOnce ) . toBe ( true , 'widget.render called once' ) ;
196196 expect ( widget . render . args [ 0 ] )
197197 . toEqual ( [ {
198- createURL : search . _createURL ,
198+ createURL : search . _createAbsoluteURL ,
199199 results,
200200 state : helper . state ,
201201 helper,
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ function getFullURL(relative) {
8080 return getLocationOrigin ( ) + window . location . pathname + relative ;
8181}
8282
83- // IE <= 11 has no location.origin
83+ // IE <= 11 has no location.origin or buggy
8484function getLocationOrigin ( ) {
8585 return `${ window . location . protocol } //${ window . location . hostname } ${ window . location . port ? ':' + window . location . port : '' } ` ;
8686}
@@ -147,14 +147,15 @@ class URLSync {
147147
148148 // External API's
149149
150- createURL ( state ) {
150+ createURL ( state , { absolute } ) {
151151 let currentQueryString = this . urlUtils . readUrl ( ) ;
152152 let filteredState = state . filter ( this . trackedParameters ) ;
153153 let foreignConfig = algoliasearchHelper . url . getUnrecognizedParametersInQueryString ( currentQueryString , { mapping : this . mapping } ) ;
154154 // Add instantsearch version to reconciliate old url with newer versions
155155 foreignConfig . is_v = majorVersionNumber ;
156+ const relative = this . urlUtils . createURL ( algoliasearchHelper . url . getQueryStringFromState ( filteredState , { mapping : this . mapping } ) ) ;
156157
157- return this . urlUtils . createURL ( algoliasearchHelper . url . getQueryStringFromState ( filteredState , { mapping : this . mapping } ) ) ;
158+ return absolute ? getFullURL ( relative ) : relative ;
158159 }
159160
160161 onHistoryChange ( fn ) {
You can’t perform that action at this time.
0 commit comments