Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b669bfdf
Unverified
Commit
b669bfdf
authored
Apr 20, 2020
by
Emil Tullstedt
Committed by
GitHub
Apr 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dashboard: Add failsafe for slug generation (#23709)
parent
c0635947
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
+13
-1
pkg/models/dashboards.go
+13
-1
No files found.
pkg/models/dashboards.go
View file @
b669bfdf
package
models
import
(
"encoding/base64"
"errors"
"fmt"
"strings"
...
...
@@ -189,7 +190,18 @@ func (dash *Dashboard) UpdateSlug() {
}
func
SlugifyTitle
(
title
string
)
string
{
return
slug
.
Make
(
strings
.
ToLower
(
title
))
s
:=
slug
.
Make
(
strings
.
ToLower
(
title
))
if
s
==
""
{
// If the dashboard name is only characters outside of the
// sluggable characters, the slug creation will return an
// empty string which will mess up URLs. This failsafe picks
// that up and creates the slug as a base64 identifier instead.
s
=
base64
.
RawURLEncoding
.
EncodeToString
([]
byte
(
title
))
if
slug
.
MaxLength
!=
0
&&
len
(
s
)
>
slug
.
MaxLength
{
s
=
s
[
:
slug
.
MaxLength
]
}
}
return
s
}
// GetUrl return the html url for a folder if it's folder, otherwise for a dashboard
...
...
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