@sierra-95/svelte-scaffold 1.2.19 → 1.2.20

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.
@@ -1,7 +1,7 @@
1
- export declare function buildRedirectUrl(baseUrl: string, redirectTo?: string): string;
1
+ export declare function buildRedirectUrl(baseUrl: string, redirectTo?: string, extraParameters?: Record<string, string>): string;
2
2
  type RedirectOptions = {
3
3
  replaceState?: boolean;
4
4
  useHardRedirect?: boolean;
5
5
  };
6
- export declare function handleRedirect(baseUrl: string, redirectTo?: string, options?: RedirectOptions): void;
6
+ export declare function handleRedirect(baseUrl: string, redirectTo?: string, options?: RedirectOptions, extraParameters?: Record<string, string>): void;
7
7
  export {};
@@ -14,16 +14,23 @@ function sanitizeRedirect(redirectTo) {
14
14
  }
15
15
  return redirectTo;
16
16
  }
17
- export function buildRedirectUrl(baseUrl, redirectTo) {
17
+ export function buildRedirectUrl(baseUrl, redirectTo, extraParameters = {}) {
18
18
  const safe = sanitizeRedirect(redirectTo);
19
- return safe
20
- ? `${baseUrl}?redirectTo=${encodeURIComponent(safe)}`
21
- : baseUrl;
19
+ const url = new URL(baseUrl, window.location.origin);
20
+ Object.entries(extraParameters).forEach(([key, value]) => {
21
+ if (value !== undefined && value !== null) {
22
+ url.searchParams.set(key, value);
23
+ }
24
+ });
25
+ if (safe) {
26
+ url.searchParams.set('redirectTo', safe);
27
+ }
28
+ return url.pathname + url.search;
22
29
  }
23
- export function handleRedirect(baseUrl, redirectTo, options = {}) {
30
+ export function handleRedirect(baseUrl, redirectTo, options = {}, extraParameters = {}) {
24
31
  if (!browser)
25
32
  return;
26
- const finalUrl = buildRedirectUrl(baseUrl, redirectTo);
33
+ const finalUrl = buildRedirectUrl(baseUrl, redirectTo, extraParameters);
27
34
  const { replaceState = false, useHardRedirect = false } = options;
28
35
  if (useHardRedirect) {
29
36
  window.location.href = finalUrl;
package/dist/index.d.ts CHANGED
@@ -56,11 +56,11 @@ export { fileInputStore, resetFileInputStore, fileInputConfig } from './stores/m
56
56
  export type { FileInputStoreMediaItem } from './stores/modules/fileInput.js';
57
57
  export { layoutStore, resetLayoutStore } from './stores/modules/layout.js';
58
58
  export { addToast, removeToast, toasts } from './stores/features/toastManager.js';
59
- export { getPreviewUrlForMedia, toggleSelectForMedia, removeFileForMedia, DOCUMENT_MIME_TYPES, IMAGE_MIME_TYPES_PREVIEW } from './Hooks/preview.js';
60
- export { validateLayoutMenuSections, filterSectionsByRole } from './Hooks/layout_menu.js';
61
- export { buttonRipple } from './Hooks/button.js';
62
- export { buildSearchIndex } from './Hooks/buildSearch.js';
63
- export { isValidEmail } from './Hooks/validateForms.js';
64
- export { handleRedirect, buildRedirectUrl } from './Hooks/redirectTo.js';
65
- export type { SearchResult } from './Hooks/buildSearch.js';
59
+ export { getPreviewUrlForMedia, toggleSelectForMedia, removeFileForMedia, DOCUMENT_MIME_TYPES, IMAGE_MIME_TYPES_PREVIEW } from './Utils/preview.js';
60
+ export { validateLayoutMenuSections, filterSectionsByRole } from './Utils/layout_menu.js';
61
+ export { buttonRipple } from './Utils/button.js';
62
+ export { buildSearchIndex } from './Utils/buildSearch.js';
63
+ export { isValidEmail } from './Utils/validateForms.js';
64
+ export { handleRedirect, buildRedirectUrl } from './Utils/redirectTo.js';
65
+ export type { SearchResult } from './Utils/buildSearch.js';
66
66
  export type { Section, SectionItem } from './stores/modules/layout.js';
package/dist/index.js CHANGED
@@ -68,9 +68,9 @@ export { fileInputStore, resetFileInputStore, fileInputConfig } from './stores/m
68
68
  export { layoutStore, resetLayoutStore } from './stores/modules/layout.js';
69
69
  export { addToast, removeToast, toasts } from './stores/features/toastManager.js';
70
70
  //#######################HOOKS/UTILS########################
71
- export { getPreviewUrlForMedia, toggleSelectForMedia, removeFileForMedia, DOCUMENT_MIME_TYPES, IMAGE_MIME_TYPES_PREVIEW } from './Hooks/preview.js';
72
- export { validateLayoutMenuSections, filterSectionsByRole } from './Hooks/layout_menu.js';
73
- export { buttonRipple } from './Hooks/button.js';
74
- export { buildSearchIndex } from './Hooks/buildSearch.js';
75
- export { isValidEmail } from './Hooks/validateForms.js';
76
- export { handleRedirect, buildRedirectUrl } from './Hooks/redirectTo.js';
71
+ export { getPreviewUrlForMedia, toggleSelectForMedia, removeFileForMedia, DOCUMENT_MIME_TYPES, IMAGE_MIME_TYPES_PREVIEW } from './Utils/preview.js';
72
+ export { validateLayoutMenuSections, filterSectionsByRole } from './Utils/layout_menu.js';
73
+ export { buttonRipple } from './Utils/button.js';
74
+ export { buildSearchIndex } from './Utils/buildSearch.js';
75
+ export { isValidEmail } from './Utils/validateForms.js';
76
+ export { handleRedirect, buildRedirectUrl } from './Utils/redirectTo.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sierra-95/svelte-scaffold",
3
- "version": "1.2.19",
3
+ "version": "1.2.20",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes