chhoumann / MetaEdit

MetaEdit for Obsidian
https://bagerbach.com
GNU General Public License v3.0
393 stars 15 forks source link

Update method keeps adding "]]" #95

Closed ramon86 closed 7 months ago

ramon86 commented 1 year ago

If I use the "update" method from the API on a field and use a link with double square brackets to link to another file, repeating the action results in extra occurrences of "]]" at the end.

Example:

TestProp:: 
```dataviewjs
const {update} = app.plugins.plugins["metaedit"].api;
const activeFile = app.workspace.getActiveFile();
await update('TestProp', '[[Test]]', activeFile);
\```

(remove that last backslash, can't get formatting to work :))

The expectation is that this page simply always sets TestProp to [[Test]], but the second time it becomes [[Test]]]], the third time [[Test]]]]]], fourth [[Test]]]]]]]] etc.

jaerri commented 1 year ago

Having the same issue rn, after looking around I believe the problem comes from this regex: https://github.com/chhoumann/MetaEdit/blob/57883f619614fb2a359a9e94ac1484c8c8f7715e/src/metaController.ts#L340 image the regex only matches until the end of "value", which leaves the double square brackets behind

Proposed fix #96

ramon86 commented 7 months ago

Fixed in 1.8.2