linkノードのurlプロパティを修正 (#84)

* add test

* fix bug
This commit is contained in:
marihachi 2021-10-14 20:24:13 +09:00 committed by GitHub
parent 238ac6b901
commit d037c2780a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -402,9 +402,9 @@ altUrlFormat
// inline: link
link
= silent:"?"? "[" label:linkLabel "](" url:linkUrl ")"
= silent:"?"? "[" label:linkLabel "](" url:url ")"
{
return LINK((silent != null), url, mergeText(label));
return LINK((silent != null), url.props.url, mergeText(label));
}
linkLabel
@ -416,9 +416,6 @@ linkLabelPart
/ mention { return text(); /* text node */ }
/ !"]" @inline
linkUrl
= url { return text(); }
// inline: fn
fn

View file

@ -961,6 +961,17 @@ hoge`;
assert.deepStrictEqual(mfm.parse(input), output);
});
it('with angle brackets url', () => {
const input = '[official instance](<https://misskey.io/@ai>).';
const output = [
LINK(false, 'https://misskey.io/@ai', [
TEXT('official instance')
]),
TEXT('.')
];
assert.deepStrictEqual(mfm.parse(input), output);
});
it('do not yield url node even if label is recognisable as a url', () => {
const input = 'official instance: [https://misskey.io/@ai](https://misskey.io/@ai).';
const output = [