mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-22 05:55:13 +00:00
understand other URL schemes too (#73)
This commit is contained in:
parent
88ecadba67
commit
a7315926ab
2 changed files with 36 additions and 0 deletions
|
@ -389,6 +389,11 @@ altUrlFormat
|
||||||
{
|
{
|
||||||
return text();
|
return text();
|
||||||
}
|
}
|
||||||
|
// URL scheme as defined in https://url.spec.whatwg.org/#url-scheme-string
|
||||||
|
/ [a-zA-Z] [-a-zA-Z0-9+.]* ":" (!(">" / _) CHAR)+
|
||||||
|
{
|
||||||
|
return text();
|
||||||
|
}
|
||||||
|
|
||||||
// inline: link
|
// inline: link
|
||||||
|
|
||||||
|
@ -412,6 +417,11 @@ linkLabelPart
|
||||||
|
|
||||||
linkUrl
|
linkUrl
|
||||||
= url { return text(); }
|
= url { return text(); }
|
||||||
|
// URL scheme as defined in https://url.spec.whatwg.org/#url-scheme-string
|
||||||
|
/ [a-zA-Z] [-a-zA-Z0-9+.]* ":" (!(")" / _) CHAR)+
|
||||||
|
{
|
||||||
|
return text();
|
||||||
|
}
|
||||||
|
|
||||||
// inline: fn
|
// inline: fn
|
||||||
|
|
||||||
|
|
|
@ -882,6 +882,22 @@ hoge`;
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(mfm.parse(input), output);
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('do not match other schemes in url withouth angle brackets', () => {
|
||||||
|
const input = 'oops:url';
|
||||||
|
const output = [
|
||||||
|
TEXT('oops:url'),
|
||||||
|
];
|
||||||
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('match other schemes in url with angle brackets', () => {
|
||||||
|
const input = '<gemini://example.com>';
|
||||||
|
const output = [
|
||||||
|
N_URL('gemini://example.com', true),
|
||||||
|
];
|
||||||
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('link', () => {
|
describe('link', () => {
|
||||||
|
@ -962,6 +978,16 @@ hoge`;
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(mfm.parse(input), output);
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('match other schemes without angle brackets', () => {
|
||||||
|
const input = '[send email](mailto:nobody@example.com?subject=test)';
|
||||||
|
const output = [
|
||||||
|
LINK(false, 'mailto:nobody@example.com?subject=test', [
|
||||||
|
TEXT('send email')
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fn v1', () => {
|
describe('fn v1', () => {
|
||||||
|
|
Loading…
Reference in a new issue