Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
cb2b2154
Commit
cb2b2154
authored
Jun 23, 2021
by
Mickaël Menu
Committed by
Robert Knight
Jun 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix exception in textMatchScore() when `text` is empty
parent
0de918ff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
match-quote.js
src/annotator/anchoring/match-quote.js
+2
-2
No files found.
src/annotator/anchoring/match-quote.js
View file @
cb2b2154
...
@@ -54,7 +54,7 @@ function search(text, str, maxErrors) {
...
@@ -54,7 +54,7 @@ function search(text, str, maxErrors) {
*/
*/
function
textMatchScore
(
text
,
str
)
{
function
textMatchScore
(
text
,
str
)
{
/* istanbul ignore next - `scoreMatch` will never pass an empty string */
/* istanbul ignore next - `scoreMatch` will never pass an empty string */
if
(
str
.
length
===
0
)
{
if
(
str
.
length
===
0
||
text
.
length
===
0
)
{
return
0.0
;
return
0.0
;
}
}
const
matches
=
search
(
text
,
str
,
str
.
length
);
const
matches
=
search
(
text
,
str
,
str
.
length
);
...
@@ -116,7 +116,7 @@ export function matchQuote(text, quote, context = {}) {
...
@@ -116,7 +116,7 @@ export function matchQuote(text, quote, context = {}) {
const
prefixScore
=
context
.
prefix
const
prefixScore
=
context
.
prefix
?
textMatchScore
(
?
textMatchScore
(
text
.
slice
(
match
.
start
-
context
.
prefix
.
length
,
match
.
start
),
text
.
slice
(
Math
.
max
(
0
,
match
.
start
-
context
.
prefix
.
length
)
,
match
.
start
),
context
.
prefix
context
.
prefix
)
)
:
1.0
;
:
1.0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment