@pradip1995/segment-primitives 0.4.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-primitives",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,26 +18,26 @@
18
18
  "./format-price": "./src/format-price.ts",
19
19
  "./section-variants": "./src/section-variants.ts",
20
20
  "./product-variants": "./src/product-variants.ts",
21
- "./product-selection-context": "./src/product-selection-context.tsx"
21
+ "./product-selection-context": "./src/product-selection-context.tsx",
22
+ "./is-next-redirect": "./src/is-next-redirect.ts"
23
+ },
24
+ "scripts": {
25
+ "typecheck": "tsc --noEmit",
26
+ "lint": "tsc --noEmit"
22
27
  },
23
28
  "peerDependencies": {
24
29
  "@medusajs/types": "^2.0.0",
25
30
  "@pradip1995/commerce-core": "^4.0.0",
26
31
  "@pradip1995/plugin-sdk": "^0.2.0",
32
+ "next": ">=15",
27
33
  "react": ">=19",
28
- "react-dom": ">=19",
29
- "next": ">=15"
34
+ "react-dom": ">=19"
30
35
  },
31
- "dependencies": {},
32
36
  "devDependencies": {
33
37
  "@medusajs/types": "^2.0.0",
34
38
  "@pradip1995/plugin-sdk": "^0.2.0",
35
39
  "@types/react": "^19",
36
40
  "react": "19.0.3",
37
41
  "typescript": "^5.7.2"
38
- },
39
- "scripts": {
40
- "typecheck": "tsc --noEmit",
41
- "lint": "tsc --noEmit"
42
42
  }
43
- }
43
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Next.js `redirect()` / `notFound()` throw special control-flow errors.
3
+ * Catch blocks must rethrow these — never render `err.message` ("NEXT_REDIRECT").
4
+ */
5
+ export function isNextRedirect(err: unknown): boolean {
6
+ if (!err || typeof err !== "object") return false
7
+
8
+ const digest =
9
+ "digest" in err ? String((err as { digest?: unknown }).digest ?? "") : ""
10
+ if (
11
+ digest.includes("NEXT_REDIRECT") ||
12
+ digest.includes("NEXT_HTTP_ERROR_FALLBACK") ||
13
+ digest.includes("NEXT_NOT_FOUND")
14
+ ) {
15
+ return true
16
+ }
17
+
18
+ const message =
19
+ err instanceof Error
20
+ ? err.message
21
+ : "message" in err
22
+ ? String((err as { message?: unknown }).message ?? "")
23
+ : ""
24
+
25
+ return (
26
+ message === "NEXT_REDIRECT" ||
27
+ message === "NEXT_NOT_FOUND" ||
28
+ message.includes("NEXT_REDIRECT")
29
+ )
30
+ }