Skip to content

Commit c5d5eb3

Browse files
committed
tweaking path index calculation in getHandler method so paths are more reliably caught
1 parent 54e0a6b commit c5d5eb3

File tree

11 files changed

+59
-57
lines changed

11 files changed

+59
-57
lines changed

TODO.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Below is a TODO list for further development of `next-auth-pubkey`.
88

99
### Tasks
1010

11+
- add tests for `getHandler` method
1112
- update diagram to include nostr
1213
- add missing tests
1314
- manual testing
@@ -19,8 +20,6 @@ Below is a TODO list for further development of `next-auth-pubkey`.
1920

2021
### Release
2122

22-
- open PR on `next-auth`
23-
- add more example repos
2423
- Once `next-auth@v5` is out of beta, ensure it's supported.
2524

2625
##### Checklist

examples/app-router/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/drizzle/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/kv/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/plain-js/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prisma/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ui-app-router/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ui-pages-router/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 40 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "next-auth-pubkey",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"type": "module",
55
"description": "A light-weight Lightning and Nostr auth provider for your Next.js app that's entirely self-hosted and plugs seamlessly into the next-auth framework.",
66
"license": "ISC",

src/main/utils/handlers.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,27 +260,27 @@ export default function getHandler(args: Arguments) {
260260
// get path from either pages or app router req/res objects
261261
const path = (res as any)?.params
262262
? new URL((req as NextRequest).nextUrl).pathname
263-
: (req as any)?.url.replace(config.baseUrl, "");
263+
: (req as any)?.url;
264264

265265
let handler;
266-
if (path?.indexOf(config.apis.create) === 0) {
266+
if (path?.indexOf(config.apis.create) > -1) {
267267
return createHandler;
268-
} else if (path?.indexOf(config.apis.poll) === 0) {
268+
} else if (path?.indexOf(config.apis.poll) > -1) {
269269
return pollHandler;
270-
} else if (path?.indexOf(config.apis.callback) === 0) {
270+
} else if (path?.indexOf(config.apis.callback) > -1) {
271271
return callbackHandler;
272-
} else if (path?.indexOf(config.apis.token) === 0) {
272+
} else if (path?.indexOf(config.apis.token) > -1) {
273273
return tokenHandler;
274-
} else if (path?.indexOf(config.apis.lightningSignIn) === 0) {
274+
} else if (path?.indexOf(config.apis.lightningSignIn) > -1) {
275275
return lightningSignInHandler;
276-
} else if (path?.indexOf(config.apis.nostrSignIn) === 0) {
276+
} else if (path?.indexOf(config.apis.nostrSignIn) > -1) {
277277
return nostrSignInHandler;
278-
} else if (path?.indexOf(config.apis.avatar) === 0) {
278+
} else if (path?.indexOf(config.apis.avatar) > -1) {
279279
return avatarHandler;
280-
} else if (path?.indexOf(config.apis.qr) === 0) {
280+
} else if (path?.indexOf(config.apis.qr) > -1) {
281281
return qrHandler;
282282
} else if (
283-
path?.indexOf(config.apis.diagnostics) === 0 &&
283+
path?.indexOf(config.apis.diagnostics) > -1 &&
284284
config.flags.diagnostics
285285
) {
286286
return diagnosticsHandler;

0 commit comments

Comments
 (0)