Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Bob Public Utils
bobgroup-go-utils
Commits
6b24b1db
Commit
6b24b1db
authored
1 year ago
by
Johan de Klerk
Browse files
Options
Downloads
Patches
Plain Diff
Check for unmatched index
parent
12563292
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
logs/logs_test.go
+5
-0
5 additions, 0 deletions
logs/logs_test.go
string_utils/string_utils.go
+5
-0
5 additions, 0 deletions
string_utils/string_utils.go
with
10 additions
and
0 deletions
logs/logs_test.go
+
5
−
0
View file @
6b24b1db
...
@@ -30,3 +30,8 @@ func TestLogs(t *testing.T) {
...
@@ -30,3 +30,8 @@ func TestLogs(t *testing.T) {
// api_logs.Errorf("Debugging %d!", 456)
// api_logs.Errorf("Debugging %d!", 456)
// api_logs.Error("Info")
// api_logs.Error("Info")
}
}
func
TestSanitiseLogs
(
t
*
testing
.
T
)
{
logString
:=
"{
\n
\"
emailVerificationStatus
\"
: true,
\n
\"
keyValueMetadata
\"
: [],
\n
\"
stepUp
\"
: null,
\n
\"
riskAdvice
\"
: null
\n
}"
logs
.
SanitiseLogs
(
logString
)
}
This diff is collapsed.
Click to expand it.
string_utils/string_utils.go
+
5
−
0
View file @
6b24b1db
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/samber/lo"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/number_utils"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/number_utils"
"regexp"
"regexp"
"strconv"
"strconv"
...
@@ -65,6 +66,10 @@ func ReplaceAllRegexStringSubmatch(re *regexp.Regexp, s string, replaceWith stri
...
@@ -65,6 +66,10 @@ func ReplaceAllRegexStringSubmatch(re *regexp.Regexp, s string, replaceWith stri
lastIndex
:=
0
lastIndex
:=
0
for
_
,
v
:=
range
re
.
FindAllSubmatchIndex
([]
byte
(
s
),
-
1
)
{
for
_
,
v
:=
range
re
.
FindAllSubmatchIndex
([]
byte
(
s
),
-
1
)
{
if
lo
.
Contains
(
v
,
-
1
)
{
continue
}
if
len
(
v
)
==
regexIndexSubmatchEnd
+
1
{
if
len
(
v
)
==
regexIndexSubmatchEnd
+
1
{
// One submatch - replace the submatch with replaceWith
// One submatch - replace the submatch with replaceWith
result
+=
s
[
lastIndex
:
v
[
regexIndexSubmatchStart
]]
+
replaceWith
+
s
[
v
[
regexIndexSubmatchEnd
]
:
v
[
regexIndexMatchEnd
]]
result
+=
s
[
lastIndex
:
v
[
regexIndexSubmatchStart
]]
+
replaceWith
+
s
[
v
[
regexIndexSubmatchEnd
]
:
v
[
regexIndexMatchEnd
]]
...
...
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