@stoplight/elements-dev-portal 1.6.15 → 1.6.16

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.
@@ -12,3 +12,7 @@ export declare type NodeContentProps = {
12
12
  refResolver?: ReferenceResolver;
13
13
  };
14
14
  export declare const NodeContent: ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }: NodeContentProps) => JSX.Element;
15
+ export declare const getNodeUriParts: (uri: string) => {
16
+ fileUri: string;
17
+ pointer: string;
18
+ };
package/index.esm.js CHANGED
@@ -66,7 +66,15 @@ const LinkComponent = ({ children, href }) => {
66
66
  }
67
67
  if (href && ctx) {
68
68
  const [node, Link] = ctx;
69
- const resolvedUri = resolve(dirname(node.uri), href);
69
+ const { fileUri } = getNodeUriParts(node.uri);
70
+ const { fileUri: hrefFileUri } = getNodeUriParts(href);
71
+ let resolvedUri;
72
+ if (hrefFileUri) {
73
+ resolvedUri = resolve(dirname(fileUri), href);
74
+ }
75
+ else {
76
+ resolvedUri = resolve(fileUri, href);
77
+ }
70
78
  const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
71
79
  const decodedUrl = decodeURIComponent(href);
72
80
  const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
@@ -85,7 +93,15 @@ function getBundledUrl(url) {
85
93
  searchParams.append('deref', 'optimizedBundle');
86
94
  bundledUrl.search = searchParams.toString();
87
95
  return bundledUrl.toString();
88
- }
96
+ }
97
+ const getNodeUriParts = (uri) => {
98
+ const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
99
+ if (parts.length === 1) {
100
+ return { fileUri: '', pointer: parts[0] || '' };
101
+ }
102
+ const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
103
+ return { fileUri, pointer: parts[2] || '' };
104
+ };
89
105
 
90
106
  const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
91
107
  const listBoxRef = React.useRef(null);
@@ -202,7 +218,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
202
218
  React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
203
219
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
204
220
 
205
- const appVersion = '1.6.15';
221
+ const appVersion = '1.6.16';
206
222
 
207
223
  class ResponseError extends Error {
208
224
  constructor(message, responseCode) {
package/index.js CHANGED
@@ -93,7 +93,15 @@ const LinkComponent = ({ children, href }) => {
93
93
  }
94
94
  if (href && ctx) {
95
95
  const [node, Link] = ctx;
96
- const resolvedUri = path.resolve(path.dirname(node.uri), href);
96
+ const { fileUri } = getNodeUriParts(node.uri);
97
+ const { fileUri: hrefFileUri } = getNodeUriParts(href);
98
+ let resolvedUri;
99
+ if (hrefFileUri) {
100
+ resolvedUri = path.resolve(path.dirname(fileUri), href);
101
+ }
102
+ else {
103
+ resolvedUri = path.resolve(fileUri, href);
104
+ }
97
105
  const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
98
106
  const decodedUrl = decodeURIComponent(href);
99
107
  const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
@@ -112,7 +120,15 @@ function getBundledUrl(url) {
112
120
  searchParams.append('deref', 'optimizedBundle');
113
121
  bundledUrl.search = searchParams.toString();
114
122
  return bundledUrl.toString();
115
- }
123
+ }
124
+ const getNodeUriParts = (uri) => {
125
+ const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
126
+ if (parts.length === 1) {
127
+ return { fileUri: '', pointer: parts[0] || '' };
128
+ }
129
+ const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
130
+ return { fileUri, pointer: parts[2] || '' };
131
+ };
116
132
 
117
133
  const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
118
134
  const listBoxRef = React__namespace.useRef(null);
@@ -229,7 +245,7 @@ const UpgradeToStarter = () => (React__default["default"].createElement(mosaic.F
229
245
  React__default["default"].createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, size: "4x" }),
230
246
  React__default["default"].createElement(mosaic.Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
231
247
 
232
- const appVersion = '1.6.15';
248
+ const appVersion = '1.6.16';
233
249
 
234
250
  class ResponseError extends Error {
235
251
  constructor(message, responseCode) {
package/index.mjs CHANGED
@@ -66,7 +66,15 @@ const LinkComponent = ({ children, href }) => {
66
66
  }
67
67
  if (href && ctx) {
68
68
  const [node, Link] = ctx;
69
- const resolvedUri = resolve(dirname(node.uri), href);
69
+ const { fileUri } = getNodeUriParts(node.uri);
70
+ const { fileUri: hrefFileUri } = getNodeUriParts(href);
71
+ let resolvedUri;
72
+ if (hrefFileUri) {
73
+ resolvedUri = resolve(dirname(fileUri), href);
74
+ }
75
+ else {
76
+ resolvedUri = resolve(fileUri, href);
77
+ }
70
78
  const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
71
79
  const decodedUrl = decodeURIComponent(href);
72
80
  const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
@@ -85,7 +93,15 @@ function getBundledUrl(url) {
85
93
  searchParams.append('deref', 'optimizedBundle');
86
94
  bundledUrl.search = searchParams.toString();
87
95
  return bundledUrl.toString();
88
- }
96
+ }
97
+ const getNodeUriParts = (uri) => {
98
+ const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
99
+ if (parts.length === 1) {
100
+ return { fileUri: '', pointer: parts[0] || '' };
101
+ }
102
+ const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
103
+ return { fileUri, pointer: parts[2] || '' };
104
+ };
89
105
 
90
106
  const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
91
107
  const listBoxRef = React.useRef(null);
@@ -202,7 +218,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
202
218
  React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
203
219
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
204
220
 
205
- const appVersion = '1.6.15';
221
+ const appVersion = '1.6.16';
206
222
 
207
223
  class ResponseError extends Error {
208
224
  constructor(message, responseCode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-dev-portal",
3
- "version": "1.6.15",
3
+ "version": "1.6.16",
4
4
  "description": "UI components for composing beautiful developer documentation.",
5
5
  "keywords": [],
6
6
  "main": "./index.js",
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const appVersion = "1.6.15";
1
+ export declare const appVersion = "1.6.16";