remove frontmatter

This commit is contained in:
Maxime Cannoodt 2022-06-29 13:30:40 +02:00
parent d7b5de735f
commit d0de4040ef
2 changed files with 13 additions and 0 deletions

View File

@ -13,6 +13,7 @@ export class NoteSharingService {
* @returns link to shared note with attached decryption key.
*/
public async shareNote(mdText: string): Promise<string> {
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] == "/") {

Binary file not shown.