Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
2b817d95
Verified
Commit
2b817d95
authored
4 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: update undefined handling #275
parent
5f991d6f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
source/data/extend.mjs
+1
-1
1 addition, 1 deletion
source/data/extend.mjs
source/text/formatter.mjs
+6
-3
6 additions, 3 deletions
source/text/formatter.mjs
test/cases/text/formatter.mjs
+21
-1
21 additions, 1 deletion
test/cases/text/formatter.mjs
with
28 additions
and
5 deletions
source/data/extend.mjs
+
1
−
1
View file @
2b817d95
...
@@ -53,7 +53,7 @@ function extend(...args) {
...
@@ -53,7 +53,7 @@ function extend(...args) {
for
(
const
k
in
a
)
{
for
(
const
k
in
a
)
{
const
v
=
a
?.[
k
];
const
v
=
a
?.[
k
];
if
(
v
===
o
?.[
k
])
{
if
(
(
k
in
o
)
&&
v
===
o
?.[
k
])
{
continue
;
continue
;
}
}
...
...
This diff is collapsed.
Click to expand it.
source/text/formatter.mjs
+
6
−
3
View file @
2b817d95
...
@@ -276,7 +276,10 @@ function format(text) {
...
@@ -276,7 +276,10 @@ function format(text) {
* @private
* @private
* @license AGPLv3
* @license AGPLv3
* @since 1.12.0
* @since 1.12.0
* @param text
*
* @param {string} text
* @param {string} openMarker
* @param {string} closeMarker
* @return {string}
* @return {string}
*/
*/
function
tokenize
(
text
,
openMarker
,
closeMarker
)
{
function
tokenize
(
text
,
openMarker
,
closeMarker
)
{
...
@@ -287,6 +290,7 @@ function tokenize(text, openMarker, closeMarker) {
...
@@ -287,6 +290,7 @@ function tokenize(text, openMarker, closeMarker) {
const
callbacks
=
this
[
internalSymbol
][
"
callbacks
"
];
const
callbacks
=
this
[
internalSymbol
][
"
callbacks
"
];
while
(
true
)
{
while
(
true
)
{
const
startIndex
=
text
.
indexOf
(
openMarker
);
const
startIndex
=
text
.
indexOf
(
openMarker
);
// no marker
// no marker
if
(
startIndex
===
-
1
)
{
if
(
startIndex
===
-
1
)
{
...
@@ -339,7 +343,7 @@ function tokenize(text, openMarker, closeMarker) {
...
@@ -339,7 +343,7 @@ function tokenize(text, openMarker, closeMarker) {
const
t1
=
key
.
split
(
"
|
"
).
shift
().
trim
();
// pipe symbol
const
t1
=
key
.
split
(
"
|
"
).
shift
().
trim
();
// pipe symbol
const
t2
=
t1
.
split
(
"
::
"
).
shift
().
trim
();
// key value delimiter
const
t2
=
t1
.
split
(
"
::
"
).
shift
().
trim
();
// key value delimiter
const
t3
=
t2
.
split
(
"
.
"
).
shift
().
trim
();
// path delimiter
const
t3
=
t2
.
split
(
"
.
"
).
shift
().
trim
();
// path delimiter
const
prefix
=
this
[
workingDataSymbol
]
?.[
t3
]
?
"
path:
"
:
"
static:
"
;
const
prefix
=
(
t3
in
this
[
workingDataSymbol
]
)
?
"
path:
"
:
"
static:
"
;
let
command
=
""
;
let
command
=
""
;
if
(
if
(
...
@@ -362,7 +366,6 @@ function tokenize(text, openMarker, closeMarker) {
...
@@ -362,7 +366,6 @@ function tokenize(text, openMarker, closeMarker) {
}
}
formatted
.
push
(
validateString
(
pipe
.
run
(
this
[
workingDataSymbol
])));
formatted
.
push
(
validateString
(
pipe
.
run
(
this
[
workingDataSymbol
])));
text
=
text
.
substring
(
endIndex
+
closeMarker
.
length
);
text
=
text
.
substring
(
endIndex
+
closeMarker
.
length
);
}
}
...
...
This diff is collapsed.
Click to expand it.
test/cases/text/formatter.mjs
+
21
−
1
View file @
2b817d95
...
@@ -4,7 +4,27 @@ import {Formatter} from "../../../source/text/formatter.mjs";
...
@@ -4,7 +4,27 @@ import {Formatter} from "../../../source/text/formatter.mjs";
describe
(
'
Formatter
'
,
function
()
{
describe
(
'
Formatter
'
,
function
()
{
// https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/47
// https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/275
describe
(
'
change empty handling
'
,
function
()
{
it
(
'
modification 1
'
,
function
()
{
const
formatter
=
new
Formatter
({
a
:
null
,
b
:
undefined
,
c
:
0
})
expect
(
formatter
.
format
(
"
${a | tostring}
"
)).
to
.
be
.
equal
(
'
null
'
);
expect
(
formatter
.
format
(
"
${b | tostring}
"
)).
to
.
be
.
equal
(
'
undefined
'
);
expect
(
formatter
.
format
(
"
${c | tostring}
"
)).
to
.
be
.
equal
(
'
0
'
);
})
})
// https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/47
describe
(
'
examples
'
,
function
()
{
describe
(
'
examples
'
,
function
()
{
it
(
'
rfc example should run
'
,
function
()
{
it
(
'
rfc example should run
'
,
function
()
{
...
...
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