diff --git a/plugin/src/NoteSharingService.ts b/plugin/src/NoteSharingService.ts index b7cca26..d66179a 100644 --- a/plugin/src/NoteSharingService.ts +++ b/plugin/src/NoteSharingService.ts @@ -13,6 +13,7 @@ export class NoteSharingService { * @returns link to shared note with attached decryption key. */ public async shareNote(mdText: string): Promise { + mdText = this.sanitizeNote(mdText); const cryptData = encryptMarkdown(mdText); let url = await this.postNote(cryptData.ciphertext, cryptData.hmac); url += `#${cryptData.key}`; @@ -34,6 +35,18 @@ export class NoteSharingService { throw Error("Did not get expected response from server on note POST."); } + private sanitizeNote(mdText: string): string { + mdText = mdText.trim(); + const match = mdText.match( + /^(?:---\s*\n)(?:(?:.*?\n)*?)(?:---)((?:.|\n|\r)*)/ + ); + if (match) { + mdText = match[1].trim(); + } + console.log(mdText); + return mdText; + } + public set serverUrl(newUrl: string) { newUrl = newUrl.replace(/([^:]\/)\/+/g, "$1"); if (newUrl[newUrl.length - 1] == "/") { diff --git a/server/prisma/dev.db b/server/prisma/dev.db index bbeb8af..e5cad23 100644 Binary files a/server/prisma/dev.db and b/server/prisma/dev.db differ