Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sfm-js
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dakkar
sfm-js
Commits
1ee9f953
Commit
1ee9f953
authored
3 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Add url tests
parent
229eb1e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/parser.ts
+107
-0
107 additions, 0 deletions
test/parser.ts
with
107 additions
and
0 deletions
test/parser.ts
+
107
−
0
View file @
1ee9f953
...
...
@@ -593,6 +593,14 @@ describe('FullParser', () => {
describe
(
'
url
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
https://misskey.io/@ai
'
;
const
output
=
[
N_URL
(
'
https://misskey.io/@ai
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
with other texts
'
,
()
=>
{
const
input
=
'
official instance: https://misskey.io/@ai.
'
;
const
output
=
[
TEXT
(
'
official instance:
'
),
...
...
@@ -601,6 +609,105 @@ describe('FullParser', () => {
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore trailing period
'
,
()
=>
{
const
input
=
'
https://misskey.io/@ai.
'
;
const
output
=
[
N_URL
(
'
https://misskey.io/@ai
'
),
TEXT
(
'
.
'
)
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore trailing periods
'
,
()
=>
{
const
input
=
'
https://misskey.io/@ai...
'
;
const
output
=
[
N_URL
(
'
https://misskey.io/@ai
'
),
TEXT
(
'
...
'
)
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
with comma
'
,
()
=>
{
const
input
=
'
https://example.com/foo?bar=a,b
'
;
const
output
=
[
N_URL
(
'
https://example.com/foo?bar=a,b
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore trailing comma
'
,
()
=>
{
const
input
=
'
https://example.com/foo, bar
'
;
const
output
=
[
N_URL
(
'
https://example.com/foo
'
),
TEXT
(
'
, bar
'
)
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
with brackets
'
,
()
=>
{
const
input
=
'
https://example.com/foo(bar)
'
;
const
output
=
[
N_URL
(
'
https://example.com/foo(bar)
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore parent brackets
'
,
()
=>
{
const
input
=
'
(https://example.com/foo)
'
;
const
output
=
[
TEXT
(
'
(
'
),
N_URL
(
'
https://example.com/foo
'
),
TEXT
(
'
)
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore parent brackets (2)
'
,
()
=>
{
const
input
=
'
(foo https://example.com/foo)
'
;
const
output
=
[
TEXT
(
'
(foo
'
),
N_URL
(
'
https://example.com/foo
'
),
TEXT
(
'
)
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore parent brackets with internal brackets
'
,
()
=>
{
const
input
=
'
(https://example.com/foo(bar))
'
;
const
output
=
[
TEXT
(
'
(
'
),
N_URL
(
'
https://example.com/foo(bar)
'
),
TEXT
(
'
)
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore parent []
'
,
()
=>
{
const
input
=
'
foo [https://example.com/foo] bar
'
;
const
output
=
[
TEXT
(
'
foo [
'
),
N_URL
(
'
https://example.com/foo
'
),
TEXT
(
'
] bar
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore non-ascii characters contained url without angle brackets
'
,
()
=>
{
const
input
=
'
https://大石泉すき.example.com
'
;
const
output
=
[
TEXT
(
'
https://大石泉すき.example.com
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
match non-ascii characters contained url with angle brackets
'
,
()
=>
{
const
input
=
'
<https://大石泉すき.example.com>
'
;
const
output
=
[
N_URL
(
'
https://大石泉すき.example.com
'
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
});
describe
(
'
link
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment