chore: run prettier

This commit is contained in:
Roman Hotsiy 2018-07-23 11:17:31 +03:00
parent b41b181dd0
commit 2ff726649c
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 18 additions and 11 deletions

View File

@ -33,7 +33,10 @@ export class RequestSamples extends React.Component<RequestSamplesProps> {
</TabList>
{hasBodySample && (
<TabPanel key="payload">
<div> <PayloadSamples content={requestBodyContent!} /> </div>
<div>
{' '}
<PayloadSamples content={requestBodyContent!} />{' '}
</div>
</TabPanel>
)}
{samples.map(sample => (

View File

@ -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', () => {

View File

@ -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
}