Merge pull request #46 from reedloden/master
Allow HSTS max_age values to be a string or an integer
This commit is contained in:
Коммит
65bbdc3b09
|
@ -41,7 +41,7 @@ module SecureHeaders
|
|||
if @config.is_a? Hash
|
||||
if !@config[:max_age]
|
||||
raise STSBuildError.new("No max-age was supplied.")
|
||||
elsif @config[:max_age] !~ /\A\d+\z/
|
||||
elsif @config[:max_age].to_s !~ /\A\d+\z/
|
||||
raise STSBuildError.new("max-age must be a number. #{@config[:max_age]} was supplied.")
|
||||
end
|
||||
else
|
||||
|
|
|
@ -28,6 +28,18 @@ module SecureHeaders
|
|||
|
||||
context "with an invalid configuration" do
|
||||
context "with a hash argument" do
|
||||
it "should allow string values for max-age" do
|
||||
lambda {
|
||||
StrictTransportSecurity.new(:max_age => '1234')
|
||||
}.should_not raise_error
|
||||
end
|
||||
|
||||
it "should allow integer values for max-age" do
|
||||
lambda {
|
||||
StrictTransportSecurity.new(:max_age => 1234)
|
||||
}.should_not raise_error
|
||||
end
|
||||
|
||||
it "raises an exception with an invalid max-age" do
|
||||
lambda {
|
||||
StrictTransportSecurity.new(:max_age => 'abc123')
|
||||
|
|
Загрузка…
Ссылка в новой задаче