mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-09 20:35:48 +03:00
fix: Uniqueness of group ID when special characters exist in tags
This commit is contained in:
parent
1243095926
commit
da57b154bb
|
@ -148,6 +148,7 @@
|
||||||
"mark.js": "^8.11.1",
|
"mark.js": "^8.11.1",
|
||||||
"marked": "^4.3.0",
|
"marked": "^4.3.0",
|
||||||
"mobx-react": "^9.1.1",
|
"mobx-react": "^9.1.1",
|
||||||
|
"nanoid": "^5.1.2",
|
||||||
"openapi-sampler": "^1.5.0",
|
"openapi-sampler": "^1.5.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"perfect-scrollbar": "^1.5.5",
|
"perfect-scrollbar": "^1.5.5",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { action, observable, makeObservable } from 'mobx';
|
import { action, observable, makeObservable } from 'mobx';
|
||||||
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
import type { OpenAPIExternalDocumentation, OpenAPITag } from '../../types';
|
import type { OpenAPIExternalDocumentation, OpenAPITag } from '../../types';
|
||||||
import { safeSlugify } from '../../utils';
|
import { safeSlugify } from '../../utils';
|
||||||
|
@ -37,8 +38,11 @@ export class GroupModel implements IMenuItem {
|
||||||
) {
|
) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
|
const safeGroupName = safeSlugify(tagOrGroup.name);
|
||||||
|
const groupId = [type, '/', safeGroupName, `_${nanoid(8)}`].join('');
|
||||||
|
|
||||||
// markdown headings already have ids calculated as they are needed for heading anchors
|
// markdown headings already have ids calculated as they are needed for heading anchors
|
||||||
this.id = (tagOrGroup as MarkdownHeading).id || type + '/' + safeSlugify(tagOrGroup.name);
|
this.id = (tagOrGroup as MarkdownHeading).id || groupId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = tagOrGroup['x-displayName'] || tagOrGroup.name;
|
this.name = tagOrGroup['x-displayName'] || tagOrGroup.name;
|
||||||
this.level = (tagOrGroup as MarkdownHeading).level || 1;
|
this.level = (tagOrGroup as MarkdownHeading).level || 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user