Skip to content

Commit

Permalink
handle empty allowed strings
Browse files Browse the repository at this point in the history
  • Loading branch information
markusahlstrand committed Aug 17, 2024
1 parent 4c2f6bc commit f578b65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/kysely/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @authhero/kysely-adapter

## 0.7.2

### Patch Changes

- Handle empty allowed strings

## 0.7.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/kysely/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.7.1",
"version": "0.7.2",
"files": [
"dist"
],
Expand Down
15 changes: 12 additions & 3 deletions packages/kysely/src/applications/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import { Kysely } from "kysely";
import { Application, ApplicationInsert } from "@authhero/adapter-interfaces";
import { Database } from "../db";

function toJsonString(value: string) {
return JSON.stringify(
value
.split(",")
.map((item) => item.trim())
.filter((item) => item.length),
);
}

export function create(db: Kysely<Database>) {
return async (
tenant_id: string,
Expand All @@ -17,9 +26,9 @@ export function create(db: Kysely<Database>) {
allowed_origins: params.allowed_origins,
};

const allowed_origins = JSON.stringify(params.allowed_origins.split(","));
const allowed_callback_urls = JSON.stringify(params.callbacks.split(","));
const callbacks = JSON.stringify(params.callbacks.split(","));
const allowed_origins = toJsonString(params.allowed_origins);
const allowed_callback_urls = toJsonString(params.callbacks);
const callbacks = toJsonString(params.callbacks);

await db
.insertInto("applications")
Expand Down

0 comments on commit f578b65

Please sign in to comment.