mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 12:03:44 +03:00
chore: run prettier
This commit is contained in:
parent
b41b181dd0
commit
2ff726649c
|
@ -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 => (
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user