Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
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
osuny
Admin
Commits
d9c06fcf
Commit
d9c06fcf
authored
2 years ago
by
pabois
Browse files
Options
Downloads
Patches
Plain Diff
factorize method
parent
1467fc8e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/website/page/with_path.rb
+1
-3
1 addition, 3 deletions
app/models/communication/website/page/with_path.rb
app/services/static.rb
+5
-0
5 additions, 0 deletions
app/services/static.rb
with
6 additions
and
3 deletions
app/models/communication/website/page/with_path.rb
+
1
−
3
View file @
d9c06fcf
...
...
@@ -29,10 +29,8 @@ module Communication::Website::Page::WithPath
return
unless
published
return
if
website
.
url
.
blank?
# do not use a global Static.clean here because url has protocol with 2 slashes!
website_url
=
website
.
url
# remove trailing slash if needed, because path begins with a slash
website_url
=
website_url
[
0
..-
2
]
if
website_url
.
end_with?
(
'/'
)
"
#{
website_url
}#{
Static
.
clean_path
path
}
"
"
#{
Static
.
remove_trailing_slash
website
.
url
}#{
Static
.
clean_path
path
}
"
end
protected
...
...
This diff is collapsed.
Click to expand it.
app/services/static.rb
+
5
−
0
View file @
d9c06fcf
...
...
@@ -4,6 +4,11 @@ class Static
path
.
gsub
(
"//"
,
'/'
)
end
def
self
.
remove_trailing_slash
(
string
)
string
=
string
[
0
..-
2
]
if
string
.
end_with?
(
'/'
)
string
end
def
self
.
render
(
template_static
,
about
,
website
)
code
=
ApplicationController
.
render
(
template:
template_static
,
...
...
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