Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
8c843cee
Commit
8c843cee
authored
Sep 16, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
middleware: Add StripExt to Context type for stripping extensions from paths
parent
9dfb940d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
middleware/context.go
middleware/context.go
+13
-0
No files found.
middleware/context.go
View file @
8c843cee
...
...
@@ -131,6 +131,19 @@ func (c Context) Truncate(input string, length int) string {
return
input
}
// StripExt returns the input string without the extension,
// which is the suffix starting with the final '.' character
// but not before the final path separator ('/') character.
// If there is no extension, the whole input is returned.
func
(
c
Context
)
StripExt
(
path
string
)
string
{
for
i
:=
len
(
path
)
-
1
;
i
>=
0
&&
path
[
i
]
!=
'/'
;
i
--
{
if
path
[
i
]
==
'.'
{
return
path
[
:
i
]
}
}
return
path
}
// Replace replaces instances of find in input with replacement.
func
(
c
Context
)
Replace
(
input
,
find
,
replacement
string
)
string
{
return
strings
.
Replace
(
input
,
find
,
replacement
,
-
1
)
...
...
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