From 48dbe8bf774873090088916c1fdf8ac32c85f4bc Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Tue, 15 Aug 2017 14:19:11 +0300 Subject: [PATCH] use createSlug --- src/components/ListingCard/ListingCard.js | 3 ++- src/components/SearchMapListingCard/SearchMapListingCard.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ListingCard/ListingCard.js b/src/components/ListingCard/ListingCard.js index 840c3838..80d461db 100644 --- a/src/components/ListingCard/ListingCard.js +++ b/src/components/ListingCard/ListingCard.js @@ -5,6 +5,7 @@ import { NamedLink, ResponsiveImage } from '../../components'; import * as propTypes from '../../util/propTypes'; import { convertMoneyToNumber } from '../../util/currency'; import { ensureListing, ensureUser } from '../../util/data'; +import { createSlug } from '../../util/urlHelpers'; import css from './ListingCard.css'; @@ -34,7 +35,7 @@ export const ListingCardComponent = props => { const currentListing = ensureListing(listing); const id = currentListing.id.uuid; const { title = '', price } = currentListing.attributes; - const slug = encodeURIComponent(title.split(' ').join('-')); + const slug = createSlug(title); const author = ensureUser(listing.author); const authorName = `${author.attributes.profile.firstName} ${author.attributes.profile.lastName}`; const firstImage = currentListing.images && currentListing.images.length > 0 diff --git a/src/components/SearchMapListingCard/SearchMapListingCard.js b/src/components/SearchMapListingCard/SearchMapListingCard.js index 2c627558..2f813a0c 100644 --- a/src/components/SearchMapListingCard/SearchMapListingCard.js +++ b/src/components/SearchMapListingCard/SearchMapListingCard.js @@ -9,6 +9,7 @@ import { formatMoney } from '../../util/currency'; import config from '../../config'; import { withFlattenedRoutes } from '../../util/contextHelpers'; import { createResourceLocatorString } from '../../util/routes'; +import { createSlug } from '../../util/urlHelpers'; import { ResponsiveImage } from '../../components'; import css from './SearchMapListingCard.css'; @@ -21,7 +22,7 @@ const getPixelPositionOffset = (width, height) => { const createURL = (flattenedRoutes, history, listing) => { const id = listing.id.uuid; - const slug = encodeURIComponent(listing.attributes.title.split(' ').join('-')); + const slug = createSlug(listing.attributes.title); const pathParams = { id, slug }; return createResourceLocatorString('ListingPage', flattenedRoutes, pathParams, {}); };