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
dd676034
Commit
dd676034
authored
Jul 20, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jul 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move unicode from services to util
parent
9edc2928
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
28 deletions
+31
-28
index.js
src/sidebar/index.js
+0
-2
view-filter-test.js
src/sidebar/services/test/view-filter-test.js
+9
-1
view-filter.js
src/sidebar/services/view-filter.js
+4
-3
threading-test.js
src/sidebar/test/integration/threading-test.js
+1
-11
unicode-test.js
src/sidebar/util/test/unicode-test.js
+3
-5
unicode.js
src/sidebar/util/unicode.js
+14
-6
No files found.
src/sidebar/index.js
View file @
dd676034
...
...
@@ -130,7 +130,6 @@ import streamerService from './services/streamer';
import
tagsService
from
'./services/tags'
;
import
threadsService
from
'./services/threads'
;
import
toastMessenger
from
'./services/toast-messenger'
;
import
unicodeService
from
'./services/unicode'
;
import
viewFilterService
from
'./services/view-filter'
;
// Redux store.
...
...
@@ -167,7 +166,6 @@ function startApp(config) {
.
register
(
'tags'
,
tagsService
)
.
register
(
'threadsService'
,
threadsService
)
.
register
(
'toastMessenger'
,
toastMessenger
)
.
register
(
'unicode'
,
unicodeService
)
.
register
(
'viewFilter'
,
viewFilterService
)
.
register
(
'store'
,
store
);
...
...
src/sidebar/services/test/view-filter-test.js
View file @
dd676034
import
ViewFilter
from
'../view-filter'
;
import
ViewFilter
,
{
$imports
}
from
'../view-filter'
;
function
isoDateWithAge
(
age
)
{
return
new
Date
(
Date
.
now
()
-
age
*
1000
).
toISOString
();
...
...
@@ -27,6 +27,14 @@ describe('sidebar/services/view-filter', () => {
normalize
:
sinon
.
stub
().
returnsArg
(
0
),
};
viewFilter
=
new
ViewFilter
(
fakeUnicode
);
$imports
.
$mock
({
'../util/unicode'
:
fakeUnicode
,
});
});
afterEach
(()
=>
{
$imports
.
$restore
();
});
describe
(
'#filter'
,
()
=>
{
...
...
src/sidebar/services/view-filter.js
View file @
dd676034
...
...
@@ -3,6 +3,7 @@
*/
import
{
quote
}
from
'../util/annotation-metadata'
;
import
*
as
unicodeUtils
from
'../util/unicode'
;
// Prevent Babel inserting helper code after `@ngInject` comment below which
// breaks browserify-ngannotate.
...
...
@@ -35,8 +36,8 @@ function displayName(ann) {
* against the parsed query by the `filter` method of this class. Annotations
* which do not match the filter are then hidden.
*/
// @ngInject
export
default
function
ViewFilter
(
unicode
)
{
export
default
function
ViewFilter
()
{
/**
* Normalize a field value or query term for comparison.
*/
...
...
@@ -44,7 +45,7 @@ export default function ViewFilter(unicode) {
if
(
typeof
val
!==
'string'
)
{
return
val
;
}
return
unicode
.
fold
(
unicode
.
normalize
(
val
)).
toLowerCase
();
return
unicode
Utils
.
fold
(
unicodeUtils
.
normalize
(
val
)).
toLowerCase
();
}
/**
...
...
src/sidebar/test/integration/threading-test.js
View file @
dd676034
...
...
@@ -39,15 +39,6 @@ describe('annotation threading', function () {
let
rootThread
;
beforeEach
(
function
()
{
const
fakeUnicode
=
{
normalize
:
function
(
s
)
{
return
s
;
},
fold
:
function
(
s
)
{
return
s
;
},
};
const
fakeFeatures
=
{
flagEnabled
:
sinon
.
stub
().
returns
(
true
),
};
...
...
@@ -59,8 +50,7 @@ describe('annotation threading', function () {
.
register
(
'annotationsService'
,
()
=>
{})
.
register
(
'viewFilter'
,
viewFilterFactory
)
.
register
(
'features'
,
{
value
:
fakeFeatures
})
.
register
(
'settings'
,
{
value
:
{}
})
.
register
(
'unicode'
,
{
value
:
fakeUnicode
});
.
register
(
'settings'
,
{
value
:
{}
});
store
=
container
.
get
(
'store'
);
rootThread
=
container
.
get
(
'rootThread'
);
...
...
src/sidebar/
services
/test/unicode-test.js
→
src/sidebar/
util
/test/unicode-test.js
View file @
dd676034
import
unicodeFactory
from
'../unicode'
;
import
*
as
unicode
from
'../unicode'
;
const
unicode
=
unicodeFactory
();
describe
(
'unicode'
,
()
=>
{
describe
(
'#fold'
,
()
=>
{
describe
(
'sidebar/util/unicode'
,
()
=>
{
describe
(
'fold'
,
()
=>
{
it
(
'removes hungarian marks'
,
()
=>
{
const
text
=
'Fürge rőt róka túlszökik zsíros étkű kutyán'
;
const
decoded
=
unicode
.
fold
(
unicode
.
normalize
(
text
));
...
...
src/sidebar/
services
/unicode.js
→
src/sidebar/
util
/unicode.js
View file @
dd676034
...
...
@@ -9,10 +9,18 @@
// eslint-disable-next-line no-misleading-character-class
const
COMBINING_MARKS
=
/
[\u
0300-
\u
036F
\u
0483-
\u
0489
\u
0591-
\u
05BD
\u
05BF
\u
05C1
\u
05C2
\u
05C4
\u
05C5
\u
05C7
\u
0610-
\u
061A
\u
064B-
\u
065F
\u
0670
\u
06D6-
\u
06DC
\u
06DF-
\u
06E4
\u
06E7
\u
06E8
\u
06EA-
\u
06ED
\u
0711
\u
0730-
\u
074A
\u
07A6-
\u
07B0
\u
07EB-
\u
07F3
\u
0816-
\u
0819
\u
081B-
\u
0823
\u
0825-
\u
0827
\u
0829-
\u
082D
\u
0859-
\u
085B
\u
08E4-
\u
08FE
\u
0900-
\u
0903
\u
093A-
\u
093C
\u
093E-
\u
094F
\u
0951-
\u
0957
\u
0962
\u
0963
\u
0981-
\u
0983
\u
09BC
\u
09BE-
\u
09C4
\u
09C7
\u
09C8
\u
09CB-
\u
09CD
\u
09D7
\u
09E2
\u
09E3
\u
0A01-
\u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
109D
\u
135D-
\u
135F
\u
1712-
\u
1714
\u
1732-
\u
1734
\u
1752
\u
1753
\u
1772
\u
1773
\u
17B4-
\u
17D3
\u
17DD
\u
180B-
\u
180D
\u
18A9
\u
1920-
\u
192B
\u
1930-
\u
193B
\u
19B0-
\u
19C0
\u
19C8
\u
19C9
\u
1A17-
\u
1A1B
\u
1A55-
\u
1A5E
\u
1A60-
\u
1A7C
\u
1A7F
\u
1B00-
\u
1B04
\u
1B34-
\u
1B44
\u
1B6B-
\u
1B73
\u
1B80-
\u
1B82
\u
1BA1-
\u
1BAD
\u
1BE6-
\u
1BF3
\u
1C24-
\u
1C37
\u
1CD0-
\u
1CD2
\u
1CD4-
\u
1CE8
\u
1CED
\u
1CF2-
\u
1CF4
\u
1DC0-
\u
1DE6
\u
1DFC-
\u
1DFF
\u
20D0-
\u
20F0
\u
2CEF-
\u
2CF1
\u
2D7F
\u
2DE0-
\u
2DFF
\u
302A-
\u
302F
\u
3099
\u
309A
\u
A66F-
\u
A672
\u
A674-
\u
A67D
\u
A69F
\u
A6F0
\u
A6F1
\u
A802
\u
A806
\u
A80B
\u
A823-
\u
A827
\u
A880
\u
A881
\u
A8B4-
\u
A8C4
\u
A8E0-
\u
A8F1
\u
A926-
\u
A92D
\u
A947-
\u
A953
\u
A980-
\u
A983
\u
A9B3-
\u
A9C0
\u
AA29-
\u
AA36
\u
AA43
\u
AA4C
\u
AA4D
\u
AA7B
\u
AAB0
\u
AAB2-
\u
AAB4
\u
AAB7
\u
AAB8
\u
AABE
\u
AABF
\u
AAC1
\u
AAEB-
\u
AAEF
\u
AAF5
\u
AAF6
\u
ABE3-
\u
ABEA
\u
ABEC
\u
ABED
\u
FB1E
\u
FE00-
\u
FE0F
\u
FE20-
\u
FE26
]
/g
;
// @ngInject
export
default
function
unicode
()
{
return
{
normalize
:
str
=>
str
.
normalize
(
'NFKD'
),
fold
:
str
=>
str
.
replace
(
COMBINING_MARKS
,
''
),
};
/**
* @param {string} str
* @return {string}
*/
export
function
fold
(
str
)
{
return
str
.
replace
(
COMBINING_MARKS
,
''
);
}
/**
* @param {string} str
* @return {string}
*/
export
function
normalize
(
str
)
{
return
str
.
normalize
(
'NFKD'
);
}
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