remove frontmatter
This commit is contained in:
parent
d7b5de735f
commit
d0de4040ef
@ -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.
Loading…
Reference in New Issue
Block a user