@stoplight/elements-core 9.0.7 → 9.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -32,8 +32,8 @@ export { useRouter } from './hooks/useRouter';
32
32
  export { Styled, withStyles } from './styled';
33
33
  export { Divider, Group, ITableOfContentsTree, Item, ParsedNode, RoutingProps, TableOfContentItem } from './types';
34
34
  export { isHttpOperation, isHttpService, isHttpWebhookOperation } from './utils/guards';
35
+ export { resolveUrl } from './utils/http-spec/IServer';
35
36
  export { ReferenceResolver } from './utils/ref-resolving/ReferenceResolver';
36
37
  export { createResolvedObject } from './utils/ref-resolving/resolvedObject';
37
- export { slugify, resolveRelativeLink } from './utils/string';
38
+ export { resolveRelativeLink, slugify } from './utils/string';
38
39
  export { createElementClass } from './web-components/createElementClass';
39
- export { resolveUrl } from './utils/http-spec/IServer';
package/index.esm.js CHANGED
@@ -706,7 +706,12 @@ const convertRequestToSample = (language, library, request) => __awaiter(void 0,
706
706
  converted = converted || null;
707
707
  }
708
708
  if (typeof converted === 'string') {
709
- converted = converted.replace(/%7B/g, '{').replace(/%7D/g, '}');
709
+ const urlRegex = /(https?:\/\/[^\s'"]+)/g;
710
+ converted = converted.replace(urlRegex, url => {
711
+ const [pathPart, queryPart] = url.split('?', 2);
712
+ const decodedPath = pathPart.replace(/%7B/g, '{').replace(/%7D/g, '}');
713
+ return queryPart ? `${decodedPath}?${queryPart}` : decodedPath;
714
+ });
710
715
  if (language === 'shell' && library === 'curl') {
711
716
  const isUrlEncoded = (_a = request === null || request === void 0 ? void 0 : request.headers) === null || _a === void 0 ? void 0 : _a.some(header => header.name.toLowerCase() === 'content-type' && header.value === 'application/x-www-form-urlencoded');
712
717
  if (isUrlEncoded) {
@@ -2948,6 +2953,9 @@ const Response = ({ response, onMediaTypeChange }) => {
2948
2953
  };
2949
2954
  Response.displayName = 'HttpOperation.Response';
2950
2955
  const codeToIntentVal = (code) => {
2956
+ if (typeof code !== 'string' || code.trim() === '') {
2957
+ return 'default';
2958
+ }
2951
2959
  const firstChar = code.charAt(0);
2952
2960
  switch (firstChar) {
2953
2961
  case '2':
package/index.js CHANGED
@@ -728,7 +728,12 @@ const convertRequestToSample = (language, library, request) => tslib.__awaiter(v
728
728
  converted = converted || null;
729
729
  }
730
730
  if (typeof converted === 'string') {
731
- converted = converted.replace(/%7B/g, '{').replace(/%7D/g, '}');
731
+ const urlRegex = /(https?:\/\/[^\s'"]+)/g;
732
+ converted = converted.replace(urlRegex, url => {
733
+ const [pathPart, queryPart] = url.split('?', 2);
734
+ const decodedPath = pathPart.replace(/%7B/g, '{').replace(/%7D/g, '}');
735
+ return queryPart ? `${decodedPath}?${queryPart}` : decodedPath;
736
+ });
732
737
  if (language === 'shell' && library === 'curl') {
733
738
  const isUrlEncoded = (_a = request === null || request === void 0 ? void 0 : request.headers) === null || _a === void 0 ? void 0 : _a.some(header => header.name.toLowerCase() === 'content-type' && header.value === 'application/x-www-form-urlencoded');
734
739
  if (isUrlEncoded) {
@@ -2970,6 +2975,9 @@ const Response = ({ response, onMediaTypeChange }) => {
2970
2975
  };
2971
2976
  Response.displayName = 'HttpOperation.Response';
2972
2977
  const codeToIntentVal = (code) => {
2978
+ if (typeof code !== 'string' || code.trim() === '') {
2979
+ return 'default';
2980
+ }
2973
2981
  const firstChar = code.charAt(0);
2974
2982
  switch (firstChar) {
2975
2983
  case '2':
package/index.mjs CHANGED
@@ -706,7 +706,12 @@ const convertRequestToSample = (language, library, request) => __awaiter(void 0,
706
706
  converted = converted || null;
707
707
  }
708
708
  if (typeof converted === 'string') {
709
- converted = converted.replace(/%7B/g, '{').replace(/%7D/g, '}');
709
+ const urlRegex = /(https?:\/\/[^\s'"]+)/g;
710
+ converted = converted.replace(urlRegex, url => {
711
+ const [pathPart, queryPart] = url.split('?', 2);
712
+ const decodedPath = pathPart.replace(/%7B/g, '{').replace(/%7D/g, '}');
713
+ return queryPart ? `${decodedPath}?${queryPart}` : decodedPath;
714
+ });
710
715
  if (language === 'shell' && library === 'curl') {
711
716
  const isUrlEncoded = (_a = request === null || request === void 0 ? void 0 : request.headers) === null || _a === void 0 ? void 0 : _a.some(header => header.name.toLowerCase() === 'content-type' && header.value === 'application/x-www-form-urlencoded');
712
717
  if (isUrlEncoded) {
@@ -2948,6 +2953,9 @@ const Response = ({ response, onMediaTypeChange }) => {
2948
2953
  };
2949
2954
  Response.displayName = 'HttpOperation.Response';
2950
2955
  const codeToIntentVal = (code) => {
2956
+ if (typeof code !== 'string' || code.trim() === '') {
2957
+ return 'default';
2958
+ }
2951
2959
  const firstChar = code.charAt(0);
2952
2960
  switch (firstChar) {
2953
2961
  case '2':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "9.0.7",
3
+ "version": "9.0.9",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -31,9 +31,9 @@
31
31
  "@stoplight/json-schema-tree": "^4.0.0",
32
32
  "@stoplight/json-schema-viewer": "4.16.3",
33
33
  "@stoplight/markdown-viewer": "^5.7.1",
34
- "@stoplight/mosaic": "^1.53.4",
35
- "@stoplight/mosaic-code-editor": "^1.53.4",
36
- "@stoplight/mosaic-code-viewer": "^1.53.4",
34
+ "@stoplight/mosaic": "^1.53.5",
35
+ "@stoplight/mosaic-code-editor": "^1.53.5",
36
+ "@stoplight/mosaic-code-viewer": "^1.53.5",
37
37
  "@stoplight/path": "^1.3.2",
38
38
  "@stoplight/react-error-boundary": "^3.0.0",
39
39
  "@stoplight/types": "^14.1.1",