@jsenv/navi 0.4.0 → 0.4.2
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/dist/jsenv_navi.js +26 -12
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/route/route.js +25 -11
package/dist/jsenv_navi.js
CHANGED
|
@@ -16760,10 +16760,10 @@ const setBaseUrl = (value) => {
|
|
|
16760
16760
|
baseUrl = new URL(value, window.location).href;
|
|
16761
16761
|
};
|
|
16762
16762
|
|
|
16763
|
-
const
|
|
16764
|
-
const
|
|
16763
|
+
const rawUrlPartSymbol = Symbol("raw_url_part");
|
|
16764
|
+
const rawUrlPart = (value) => {
|
|
16765
16765
|
return {
|
|
16766
|
-
[
|
|
16766
|
+
[rawUrlPartSymbol]: true,
|
|
16767
16767
|
value,
|
|
16768
16768
|
};
|
|
16769
16769
|
};
|
|
@@ -17041,10 +17041,16 @@ const createRoute = (urlPatternInput) => {
|
|
|
17041
17041
|
|
|
17042
17042
|
const buildRelativeUrl = (params = {}) => {
|
|
17043
17043
|
let relativeUrl = urlPatternInput;
|
|
17044
|
+
let hasRawUrlPartWithInvalidChars = false;
|
|
17044
17045
|
|
|
17045
17046
|
const encode = (value) => {
|
|
17046
|
-
if (value && value[
|
|
17047
|
-
|
|
17047
|
+
if (value && value[rawUrlPartSymbol]) {
|
|
17048
|
+
const rawValue = value.value;
|
|
17049
|
+
// Check if raw value contains invalid URL characters
|
|
17050
|
+
if (/[\s<>{}|\\^`]/.test(rawValue)) {
|
|
17051
|
+
hasRawUrlPartWithInvalidChars = true;
|
|
17052
|
+
}
|
|
17053
|
+
return rawValue;
|
|
17048
17054
|
}
|
|
17049
17055
|
return encodeURIComponent(value);
|
|
17050
17056
|
};
|
|
@@ -17074,14 +17080,22 @@ const createRoute = (urlPatternInput) => {
|
|
|
17074
17080
|
});
|
|
17075
17081
|
}
|
|
17076
17082
|
|
|
17077
|
-
return
|
|
17083
|
+
return {
|
|
17084
|
+
relativeUrl,
|
|
17085
|
+
hasRawUrlPartWithInvalidChars,
|
|
17086
|
+
};
|
|
17078
17087
|
};
|
|
17079
17088
|
const buildUrl = (params = {}) => {
|
|
17080
|
-
|
|
17081
|
-
|
|
17082
|
-
|
|
17089
|
+
const { relativeUrl, hasRawUrlPartWithInvalidChars } =
|
|
17090
|
+
buildRelativeUrl(params);
|
|
17091
|
+
let processedRelativeUrl = relativeUrl;
|
|
17092
|
+
if (processedRelativeUrl[0] === "/") {
|
|
17093
|
+
processedRelativeUrl = processedRelativeUrl.slice(1);
|
|
17083
17094
|
}
|
|
17084
|
-
|
|
17095
|
+
if (hasRawUrlPartWithInvalidChars) {
|
|
17096
|
+
return `${baseUrl}/${processedRelativeUrl}`;
|
|
17097
|
+
}
|
|
17098
|
+
const url = new URL(processedRelativeUrl, baseUrl).href;
|
|
17085
17099
|
return url;
|
|
17086
17100
|
};
|
|
17087
17101
|
route.buildUrl = buildUrl;
|
|
@@ -17091,7 +17105,7 @@ const createRoute = (urlPatternInput) => {
|
|
|
17091
17105
|
const visitedSignal = signal(false);
|
|
17092
17106
|
const relativeUrlSignal = computed(() => {
|
|
17093
17107
|
const params = paramsSignal.value;
|
|
17094
|
-
const relativeUrl = buildRelativeUrl(params);
|
|
17108
|
+
const { relativeUrl } = buildRelativeUrl(params);
|
|
17095
17109
|
return relativeUrl;
|
|
17096
17110
|
});
|
|
17097
17111
|
const disposeRelativeUrlEffect = effect(() => {
|
|
@@ -27898,4 +27912,4 @@ const useDependenciesDiff = (inputs) => {
|
|
|
27898
27912
|
return diffRef.current;
|
|
27899
27913
|
};
|
|
27900
27914
|
|
|
27901
|
-
export { ActionRenderer, ActiveKeyboardShortcuts, Button, Checkbox, CheckboxList, Col, Colgroup, Details, Editable, ErrorBoundaryContext, FontSizedSvg, Form, IconAndText, Input, Label, Link, LinkWithIcon, Overflow, Radio, RadioList, Route, RowNumberCol, RowNumberTableCell, SINGLE_SPACE_CONSTRAINT, SVGMaskOverlay, Select, SelectionContext, SummaryMarker, Tab, TabList, Table, TableCell, Tbody, TextAndCount, Thead, Tr, UITransition, actionIntegratedVia, addCustomMessage, createAction, createSelectionKeyboardShortcuts, createUniqueValueConstraint, defineRoutes, enableDebugActions, enableDebugOnDocumentLoading,
|
|
27915
|
+
export { ActionRenderer, ActiveKeyboardShortcuts, Button, Checkbox, CheckboxList, Col, Colgroup, Details, Editable, ErrorBoundaryContext, FontSizedSvg, Form, IconAndText, Input, Label, Link, LinkWithIcon, Overflow, Radio, RadioList, Route, RowNumberCol, RowNumberTableCell, SINGLE_SPACE_CONSTRAINT, SVGMaskOverlay, Select, SelectionContext, SummaryMarker, Tab, TabList, Table, TableCell, Tbody, TextAndCount, Thead, Tr, UITransition, actionIntegratedVia, addCustomMessage, createAction, createSelectionKeyboardShortcuts, createUniqueValueConstraint, defineRoutes, enableDebugActions, enableDebugOnDocumentLoading, goBack, goForward, goTo, isCellSelected, isColumnSelected, isRowSelected, openCallout, rawUrlPart, reload, removeCustomMessage, rerunActions, resource, setBaseUrl, stopLoad, stringifyTableSelectionValue, updateActions, useActionData, useActionStatus, useCellsAndColumns, useDependenciesDiff, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useKeyboardShortcuts, useNavState, useRouteStatus, useRunOnMount, useSelectableElement, useSelectionController, useSignalSync, useStateArray, valueInLocalStorage };
|
package/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export { useDocumentState } from "./src/browser_integration/document_state_signa
|
|
|
26
26
|
export { useDocumentUrl } from "./src/browser_integration/document_url_signal.js";
|
|
27
27
|
export {
|
|
28
28
|
defineRoutes,
|
|
29
|
-
|
|
29
|
+
rawUrlPart,
|
|
30
30
|
setBaseUrl,
|
|
31
31
|
useRouteStatus,
|
|
32
32
|
} from "./src/route/route.js";
|
package/package.json
CHANGED
package/src/route/route.js
CHANGED
|
@@ -13,10 +13,10 @@ export const setBaseUrl = (value) => {
|
|
|
13
13
|
baseUrl = new URL(value, window.location).href;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
export const
|
|
16
|
+
const rawUrlPartSymbol = Symbol("raw_url_part");
|
|
17
|
+
export const rawUrlPart = (value) => {
|
|
18
18
|
return {
|
|
19
|
-
[
|
|
19
|
+
[rawUrlPartSymbol]: true,
|
|
20
20
|
value,
|
|
21
21
|
};
|
|
22
22
|
};
|
|
@@ -308,10 +308,16 @@ const createRoute = (urlPatternInput) => {
|
|
|
308
308
|
|
|
309
309
|
const buildRelativeUrl = (params = {}) => {
|
|
310
310
|
let relativeUrl = urlPatternInput;
|
|
311
|
+
let hasRawUrlPartWithInvalidChars = false;
|
|
311
312
|
|
|
312
313
|
const encode = (value) => {
|
|
313
|
-
if (value && value[
|
|
314
|
-
|
|
314
|
+
if (value && value[rawUrlPartSymbol]) {
|
|
315
|
+
const rawValue = value.value;
|
|
316
|
+
// Check if raw value contains invalid URL characters
|
|
317
|
+
if (/[\s<>{}|\\^`]/.test(rawValue)) {
|
|
318
|
+
hasRawUrlPartWithInvalidChars = true;
|
|
319
|
+
}
|
|
320
|
+
return rawValue;
|
|
315
321
|
}
|
|
316
322
|
return encodeURIComponent(value);
|
|
317
323
|
};
|
|
@@ -341,14 +347,22 @@ const createRoute = (urlPatternInput) => {
|
|
|
341
347
|
});
|
|
342
348
|
}
|
|
343
349
|
|
|
344
|
-
return
|
|
350
|
+
return {
|
|
351
|
+
relativeUrl,
|
|
352
|
+
hasRawUrlPartWithInvalidChars,
|
|
353
|
+
};
|
|
345
354
|
};
|
|
346
355
|
const buildUrl = (params = {}) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
356
|
+
const { relativeUrl, hasRawUrlPartWithInvalidChars } =
|
|
357
|
+
buildRelativeUrl(params);
|
|
358
|
+
let processedRelativeUrl = relativeUrl;
|
|
359
|
+
if (processedRelativeUrl[0] === "/") {
|
|
360
|
+
processedRelativeUrl = processedRelativeUrl.slice(1);
|
|
350
361
|
}
|
|
351
|
-
|
|
362
|
+
if (hasRawUrlPartWithInvalidChars) {
|
|
363
|
+
return `${baseUrl}/${processedRelativeUrl}`;
|
|
364
|
+
}
|
|
365
|
+
const url = new URL(processedRelativeUrl, baseUrl).href;
|
|
352
366
|
return url;
|
|
353
367
|
};
|
|
354
368
|
route.buildUrl = buildUrl;
|
|
@@ -358,7 +372,7 @@ const createRoute = (urlPatternInput) => {
|
|
|
358
372
|
const visitedSignal = signal(false);
|
|
359
373
|
const relativeUrlSignal = computed(() => {
|
|
360
374
|
const params = paramsSignal.value;
|
|
361
|
-
const relativeUrl = buildRelativeUrl(params);
|
|
375
|
+
const { relativeUrl } = buildRelativeUrl(params);
|
|
362
376
|
return relativeUrl;
|
|
363
377
|
});
|
|
364
378
|
const disposeRelativeUrlEffect = effect(() => {
|