From 2ff726649c354be158231c0488b935bbee33adf3 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 23 Jul 2018 11:17:31 +0300 Subject: [PATCH] chore: run prettier --- .../RequestSamples/RequestSamples.tsx | 5 ++++- src/utils/__tests__/helpers.test.ts | 6 +++--- src/utils/helpers.ts | 18 +++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/components/RequestSamples/RequestSamples.tsx b/src/components/RequestSamples/RequestSamples.tsx index 54222c59..779bae0c 100644 --- a/src/components/RequestSamples/RequestSamples.tsx +++ b/src/components/RequestSamples/RequestSamples.tsx @@ -33,7 +33,10 @@ export class RequestSamples extends React.Component { {hasBodySample && ( -
+
+ {' '} + {' '} +
)} {samples.map(sample => ( diff --git a/src/utils/__tests__/helpers.test.ts b/src/utils/__tests__/helpers.test.ts index 0b7988b2..e73d4367 100644 --- a/src/utils/__tests__/helpers.test.ts +++ b/src/utils/__tests__/helpers.test.ts @@ -41,14 +41,14 @@ describe('Utils', () => { }); test('slugifyIfAvailable returns original value when cannot slugify the value', () => { - const willBeSlugifed = safeSlugify('some string') + const willBeSlugifed = safeSlugify('some string'); expect(willBeSlugifed).toEqual('some-string'); - const cannotBeSlugified = '가나다라 마바사' + const cannotBeSlugified = '가나다라 마바사'; // if slugify() fixes this issue, safeSlugify should be removed and replaced with original one. expect(slugify(cannotBeSlugified)).toEqual(''); expect(safeSlugify(cannotBeSlugified)).toEqual('가나다라-마바사'); - }) + }); describe('mergeObjects', () => { test('should merge Objects and all nested Ones', () => { diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 0debd57e..53703e1c 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -121,11 +121,15 @@ const isMergebleObject = (item): boolean => { * the regex codes are referenced with https://gist.github.com/mathewbyrne/1280286 */ export function safeSlugify(value: string): string { - return slugify(value) || - value.toString().toLowerCase() - .replace(/\s+/g, '-') // Replace spaces with - - .replace(/&/g, '-and-') // Replace & with 'and' - .replace(/\--+/g, '-') // Replace multiple - with single - - .replace(/^-+/, '') // Trim - from start of text - .replace(/-+$/, ''); // Trim - from end of text + return ( + slugify(value) || + value + .toString() + .toLowerCase() + .replace(/\s+/g, '-') // Replace spaces with - + .replace(/&/g, '-and-') // Replace & with 'and' + .replace(/\--+/g, '-') // Replace multiple - with single - + .replace(/^-+/, '') // Trim - from start of text + .replace(/-+$/, '') + ); // Trim - from end of text }