From 80253566c59bdb10dd35ed3247ecd2b1631691b0 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 14 Nov 2016 10:09:26 +0200 Subject: [PATCH] .org Plans: Use site.domain instead of slugToUrl helper --- client/lib/url/index.js | 9 --------- client/lib/url/test/index.js | 18 ------------------ client/me/purchases/remove-purchase/index.jsx | 5 ++--- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/client/lib/url/index.js b/client/lib/url/index.js index 234d7f42dae08..1220c69c78bea 100644 --- a/client/lib/url/index.js +++ b/client/lib/url/index.js @@ -92,14 +92,6 @@ function urlToSlug( url ) { return withoutHttp( url ).replace( /\//g, '::' ); } -function slugToUrl( slug ) { - if ( ! slug ) { - return null; - } - - return slug.replace( /::/g, '/' ); -} - export default { isOutsideCalypso, isExternal, @@ -108,7 +100,6 @@ export default { addSchemeIfMissing, setUrlScheme, urlToSlug, - slugToUrl, // [TODO]: Move lib/route/add-query-args contents here addQueryArgs }; diff --git a/client/lib/url/test/index.js b/client/lib/url/test/index.js index b339fbda7cef2..c7a5ef9384a6e 100644 --- a/client/lib/url/test/index.js +++ b/client/lib/url/test/index.js @@ -13,7 +13,6 @@ import { addSchemeIfMissing, setUrlScheme, urlToSlug, - slugToUrl, } from '../'; describe( 'withoutHttp', () => { @@ -238,20 +237,3 @@ describe( 'urlToSlug()', () => { expect( urlWithoutHttp ).to.equal( 'example.com::example::test123' ); } ); } ); - -describe( 'slugToUrl()', () => { - it( 'should return null if slug is not provided', () => { - expect( slugToUrl() ).to.be.null; - } ); - - it( 'should return null if slug is empty string', () => { - expect( slugToUrl( '' ) ).to.be.null; - } ); - - it( 'should return null convert double colons to forward slashes', () => { - const slug = 'example.com::example::test123'; - const expected = 'example.com/example/test123'; - - expect( slugToUrl( slug ) ).to.equal( expected ); - } ); -} ); diff --git a/client/me/purchases/remove-purchase/index.jsx b/client/me/purchases/remove-purchase/index.jsx index 6d3b750c4dc61..96f7b5bca2fcd 100644 --- a/client/me/purchases/remove-purchase/index.jsx +++ b/client/me/purchases/remove-purchase/index.jsx @@ -22,7 +22,6 @@ import purchasePaths from '../paths'; import { removePurchase } from 'state/purchases/actions'; import FormSectionHeading from 'components/forms/form-section-heading'; import userFactory from 'lib/user'; -import { slugToUrl } from 'lib/url'; import { isOperatorsAvailable } from 'state/ui/olark/selectors'; import olarkActions from 'lib/olark-store/actions'; @@ -138,7 +137,7 @@ const RemovePurchase = React.createClass( { notices.success( this.translate( '%(productName)s was removed from {{siteName/}}.', { args: { productName }, - components: { siteName: { slugToUrl( selectedSite.slug ) } } + components: { siteName: { selectedSite.domain } } } ), { persistent: true } ); @@ -312,7 +311,7 @@ const RemovePurchase = React.createClass( { 'Are you sure you want to remove %(productName)s from {{siteName/}}?', { args: { productName }, - components: { siteName: { slugToUrl( this.props.selectedSite.slug ) } } + components: { siteName: { this.props.selectedSite.domain } } } ) }