Skip to content

Commit

Permalink
Merge pull request #2004 from HSLdevcom/navigation-fix-for-addresses-…
Browse files Browse the repository at this point in the history
…with-special-chars

Navigation fix for addresses with special chars
  • Loading branch information
pailakka authored Nov 30, 2017
2 parents 89c054b + 193c476 commit 8efd561
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions app/component/FavouriteLocationsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import connectToStores from 'fluxible-addons-react/connectToStores';
import SwipeableViews from 'react-swipeable-views';
import { bindKeyboard } from 'react-swipeable-views-utils';
import range from 'lodash/range';
import { getPathWithEndpointObjects } from '../util/path';
import { navigateTo } from '../util/path';
import Icon from './Icon';
import FavouriteLocationContainer from './FavouriteLocationContainer';
import FavouriteLocation from './FavouriteLocation';
Expand Down Expand Up @@ -105,10 +105,15 @@ class FavouriteLocationsContainer extends React.Component {
lat,
lon,
address: locationName,
ready: true,
};

const url = getPathWithEndpointObjects(this.props.origin, location);
this.context.router.push(url);
navigateTo({
origin: this.props.origin,
destination: location,
context: '/',
router: this.context.router,
});
};

slideRenderer = ({ key, index }) => {
Expand Down
4 changes: 3 additions & 1 deletion app/util/otpStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const addressToItinerarySearch = location => {
if (location.set === false) {
return '-';
}
return `${location.address}::${location.lat},${location.lon}`;
return `${encodeURIComponent(
location.address,
)}::${location.lat},${location.lon}`;
};

export const locationToOTP = location => {
Expand Down
6 changes: 5 additions & 1 deletion app/util/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export const PREFIX_ITINERARY_SUMMARY = 'reitti';
export const stopUrl = id => id;

export const getRoutePath = (origin, destination) =>
[`/${PREFIX_ITINERARY_SUMMARY}`, origin, destination].join('/');
[
`/${PREFIX_ITINERARY_SUMMARY}`,
encodeURIComponent(decodeURIComponent(origin)),
encodeURIComponent(decodeURIComponent(destination)),
].join('/');

export const getItineraryPath = (from, to, idx) =>
[getRoutePath(from, to), idx].join('/');
Expand Down

0 comments on commit 8efd561

Please sign in to comment.