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
d53e4c34
Commit
d53e4c34
authored
Mar 16, 2021
by
Eduardo Sanz García
Committed by
Eduardo
Mar 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved string formatting of the client's version
Reordered fields according to the UI and capitalised properties.
parent
1e202a16
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
16 deletions
+32
-16
version-data-test.js
src/sidebar/helpers/test/version-data-test.js
+22
-6
version-data.js
src/sidebar/helpers/version-data.js
+10
-10
No files found.
src/sidebar/helpers/test/version-data-test.js
View file @
d53e4c34
...
...
@@ -79,22 +79,38 @@ describe('sidebar/helpers/version-data', () => {
});
describe
(
'#asFormattedString'
,
()
=>
{
[
'timestamp'
,
'account'
,
'url'
].
forEach
(
prop
=>
{
it
(
`includes a line for the value of
${
prop
}
in the string`
,
()
=>
{
[
[
'Version'
,
'version'
],
[
'User Agent'
,
'userAgent'
],
[
'URL'
,
'url'
],
[
'Fingerprint'
,
'fingerprint'
],
[
'Account'
,
'account'
],
[
'Date'
,
'timestamp'
],
].
forEach
(
prop
=>
{
it
(
`includes a line for the value of
${
prop
[
1
]}
in the string`
,
()
=>
{
const
versionData
=
new
VersionData
({},
{});
const
formatted
=
versionData
.
asFormattedString
();
const
subStr
=
`
${
prop
}
:
${
versionData
[
prop
]}
\r
\n`
;
const
subStr
=
`
${
prop
[
0
]}
:
${
versionData
[
prop
[
1
]]}
\n`
;
assert
.
include
(
formatted
,
subStr
);
});
});
});
describe
(
'#asEncodedURLString'
,
()
=>
{
[
'timestamp'
,
'account'
].
forEach
(
prop
=>
{
it
(
`includes encoded value for
${
prop
}
in URL string`
,
()
=>
{
[
[
'Version'
,
'version'
],
[
'User Agent'
,
'userAgent'
],
[
'URL'
,
'url'
],
[
'Fingerprint'
,
'fingerprint'
],
[
'Account'
,
'account'
],
[
'Date'
,
'timestamp'
],
].
forEach
(
prop
=>
{
it
(
`includes encoded value for
${
prop
[
1
]}
in URL string`
,
()
=>
{
const
versionData
=
new
VersionData
({},
{});
const
encoded
=
versionData
.
asEncodedURLString
();
const
subStr
=
encodeURIComponent
(
`
${
prop
}
:
${
versionData
[
prop
]}
\r\n`
);
const
subStr
=
encodeURIComponent
(
`
${
prop
[
0
]}
:
${
versionData
[
prop
[
1
]]}
\n`
);
assert
.
include
(
encoded
,
subStr
);
});
});
...
...
src/sidebar/helpers/version-data.js
View file @
d53e4c34
...
...
@@ -35,15 +35,15 @@ export default class VersionData {
}
}
this
.
timestamp
=
new
Date
().
toString
();
this
.
version
=
'__VERSION__'
;
// replaced by versionify
this
.
userAgent
=
window_
.
navigator
.
userAgent
;
this
.
url
=
documentInfo
.
uri
||
noValueString
;
this
.
fingerprint
=
docMeta
&&
docMeta
.
documentFingerprint
?
docMeta
.
documentFingerprint
:
noValueString
;
this
.
account
=
accountString
;
this
.
userAgent
=
window_
.
navigator
.
userAgent
;
this
.
version
=
'__VERSION__'
;
this
.
timestamp
=
new
Date
().
toString
();
}
/**
...
...
@@ -53,13 +53,13 @@ export default class VersionData {
* @return {string} - Single, multiline string representing current version data
*/
asFormattedString
()
{
let
versionString
=
''
;
for
(
let
prop
in
this
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
this
,
prop
))
{
versionString
+=
`
${
prop
}
:
${
this
[
prop
]}
\r\n`
;
}
}
return
versionString
;
return
`Version:
${
this
.
version
}
User Agent:
${
this
.
userAgent
}
URL:
${
this
.
url
}
Fingerprint:
${
this
.
fingerprint
}
Account:
${
this
.
account
}
Date:
${
this
.
timestamp
}
`
;
}
/**
...
...
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