Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
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
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
Pierre Boudes
mastodon
Commits
b922ad7a
Unverified
Commit
b922ad7a
authored
1 year ago
by
Claire
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix crash when S3_ALIAS_HOST or S3_CLOUDFRONT_HOST have a path component (#25018)
parent
2b45fecd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/helpers/application_helper.rb
+3
-3
3 additions, 3 deletions
app/helpers/application_helper.rb
spec/helpers/application_helper_spec.rb
+12
-6
12 additions, 6 deletions
spec/helpers/application_helper_spec.rb
with
15 additions
and
9 deletions
app/helpers/application_helper.rb
+
3
−
3
View file @
b922ad7a
...
...
@@ -169,11 +169,11 @@ module ApplicationHelper
end
def
storage_host
URI
::
HTTPS
.
build
(
host:
storage_host_
name
).
to_s
"https://
#{
storage_host_
var
}
"
end
def
storage_host?
storage_host_
name
.
present?
storage_host_
var
.
present?
end
def
quote_wrap
(
text
,
line_width:
80
,
break_sequence:
"
\n
"
)
...
...
@@ -234,7 +234,7 @@ module ApplicationHelper
private
def
storage_host_
name
def
storage_host_
var
ENV
.
fetch
(
'S3_ALIAS_HOST'
,
nil
)
||
ENV
.
fetch
(
'S3_CLOUDFRONT_HOST'
,
nil
)
end
end
This diff is collapsed.
Click to expand it.
spec/helpers/application_helper_spec.rb
+
12
−
6
View file @
b922ad7a
...
...
@@ -208,6 +208,18 @@ describe ApplicationHelper do
end
end
context
'when S3 alias includes a path component'
do
around
do
|
example
|
ClimateControl
.
modify
S3_ALIAS_HOST
:
's3.alias/path'
do
example
.
run
end
end
it
'returns a correct URL'
do
expect
(
helper
.
storage_host
).
to
eq
(
'https://s3.alias/path'
)
end
end
context
'when S3 cloudfront is present'
do
around
do
|
example
|
ClimateControl
.
modify
S3_CLOUDFRONT_HOST
:
's3.cloudfront'
do
...
...
@@ -219,12 +231,6 @@ describe ApplicationHelper do
expect
(
helper
.
storage_host
).
to
eq
(
'https://s3.cloudfront'
)
end
end
context
'when neither env value is present'
do
it
'returns false'
do
expect
(
helper
.
storage_host
).
to
eq
(
'https:'
)
end
end
end
describe
'storage_host?'
do
...
...
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