@slipmatio/toolbelt
Advanced tools
Comparing version 0.7.2 to 0.8.0
# Changelog | ||
## 0.8.0 (2025-01-17) | ||
- Feat: Added `getNext` to Vue utils. | ||
- Chore: bumped deps. | ||
## 0.7.2 (2025-01-13) | ||
@@ -4,0 +9,0 @@ |
@@ -6,6 +6,16 @@ import { LocationQueryValue } from 'vue-router'; | ||
* Safely extracts and validates the 'next' query parameter from the current route. | ||
* Allows any valid local paths and valid URLs to the given domains. | ||
* | ||
* @param allowedDomains - Array of allowed domains. | ||
* @param router - Optional Vue Router instance. Required when used outside of component setup. | ||
* @returns A validated path string (starting with '/') or '/' if no valid next path exists. | ||
*/ | ||
export declare function getNext(allowedDomains: string[], router?: Router): string; | ||
/** | ||
* Safely extracts and validates the 'next' query parameter from the current route. Allows only local paths. | ||
* | ||
* @param router - Optional Vue Router instance. Required when used outside of component setup. | ||
* @returns A validated path string (starting with '/') or '/' if no valid next path exists. | ||
*/ | ||
export declare function getNextPath(router?: Router): string; | ||
@@ -12,0 +22,0 @@ |
@@ -1,75 +0,7 @@ | ||
function o() { | ||
try { | ||
return typeof window > "u" && typeof document > "u"; | ||
} catch { | ||
return !0; | ||
} | ||
} | ||
function u() { | ||
if (o()) | ||
return !1; | ||
try { | ||
return !!Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
} catch { | ||
return !1; | ||
} | ||
} | ||
function s(t) { | ||
if (o()) | ||
return !1; | ||
const e = "__storage_test__"; | ||
if (t === "localStorage") | ||
try { | ||
return localStorage.setItem(e, e), localStorage.removeItem(e), !0; | ||
} catch { | ||
return !1; | ||
} | ||
else | ||
try { | ||
return sessionStorage.setItem(e, e), sessionStorage.removeItem(e), !0; | ||
} catch { | ||
return !1; | ||
} | ||
} | ||
function l(t) { | ||
if (o()) | ||
return null; | ||
let e = ""; | ||
if (document.cookie && document.cookie !== "") { | ||
const r = document.cookie.split(";"); | ||
for (let n = 0; n < r.length; n++) { | ||
const i = r[n].trim(); | ||
if (i.substring(0, t.length + 1) === t + "=") { | ||
e = decodeURIComponent(i.substring(t.length + 1)); | ||
break; | ||
} | ||
} | ||
} | ||
return e.length > 0 ? e : null; | ||
} | ||
function a(t) { | ||
if (o()) | ||
return !1; | ||
const e = document; | ||
try { | ||
const r = document.createElement("input"); | ||
return r.setAttribute("style", "opacity:0;"), r.setAttribute("value", t), e.body.appendChild(r), r.select(), e.execCommand("copy"), e.body.removeChild(r), !0; | ||
} catch { | ||
return !1; | ||
} | ||
} | ||
function c() { | ||
if (o()) | ||
return !1; | ||
const t = window.navigator.userAgent; | ||
return t.indexOf("MSIE ") > -1 || t.indexOf("Trident/") > -1; | ||
} | ||
function f() { | ||
return o() ? !1 : !c() && u() && s("localStorage"); | ||
} | ||
import { b as s, c as e, g as r, s as p } from "./toolbelt-DvaMdNEI.js"; | ||
export { | ||
f as browserIsSupported, | ||
a as copyToClipboard, | ||
l as getCookie, | ||
s as storageAvailable | ||
s as browserIsSupported, | ||
e as copyToClipboard, | ||
r as getCookie, | ||
p as storageAvailable | ||
}; |
@@ -1,14 +0,22 @@ | ||
import { useRoute as n } from "vue-router"; | ||
function u(t) { | ||
return typeof t == "string"; | ||
import { i as x, a as y } from "../toolbelt-DvaMdNEI.js"; | ||
import { useRoute as i } from "vue-router"; | ||
function n(r) { | ||
return typeof r == "string"; | ||
} | ||
function o(t) { | ||
function s(r) { | ||
let t; | ||
r ? t = r.currentRoute.value : t = i(); | ||
let e = "/"; | ||
return t.query && t.query.next && n(t.query.next) && t.query.next.startsWith("/") && (e = t.query.next), e; | ||
} | ||
function l(r, t) { | ||
let e; | ||
t ? e = t.currentRoute.value : e = n(); | ||
let r = "/"; | ||
return e.query && e.query.next && u(e.query.next) && e.query.next.startsWith("/") && (r = e.query.next), r; | ||
t ? e = t.currentRoute.value : e = i(); | ||
let u = "/"; | ||
return (e.query && e.query.next && n(e.query.next) && e.query.next.startsWith("/") || e.query && e.query.next && n(e.query.next) && x(e.query.next) && y(e.query.next, r)) && (u = e.query.next), u; | ||
} | ||
export { | ||
o as getNextPath, | ||
u as isString | ||
l as getNext, | ||
s as getNextPath, | ||
n as isString | ||
}; |
{ | ||
"name": "@slipmatio/toolbelt", | ||
"type": "module", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"main": "dist/toolbelt.js", | ||
@@ -34,12 +34,12 @@ "module": "dist/toolbelt.js", | ||
"@tsconfig/node20": "^20.1.4", | ||
"@types/node": "^22.10.6", | ||
"@types/node": "^22.10.7", | ||
"@vitejs/plugin-vue": "^5.2.1", | ||
"@vitest/coverage-v8": "2.1.8", | ||
"@vitest/coverage-v8": "3.0.1", | ||
"@vue/test-utils": "^2.4.6", | ||
"@vue/tsconfig": "^0.7.0", | ||
"happy-dom": "^16.5.3", | ||
"happy-dom": "^16.6.0", | ||
"typescript": "^5.7.3", | ||
"vite": "^6.0.7", | ||
"vite-plugin-dts": "^4.5.0", | ||
"vitest": "2.1.8", | ||
"vitest": "3.0.1", | ||
"vue": "^3.5.13", | ||
@@ -46,0 +46,0 @@ "vue-router": "^4.5.0", |
@@ -22,2 +22,3 @@ # Slipmat Toolbelt | ||
- `getNext(allowedDomains: string[], router?: Router)` - returns the value of `?next` query param or `/` | ||
- `getNextPath(router?: Router)` - returns the value of `?next` query param or `/` | ||
@@ -24,0 +25,0 @@ - `isString(value: string | LocationQueryValue[])` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
13050
13
171
70
1