Skip to content

Commit

Permalink
Merge pull request #171 from noir-cr/hahwul-dev
Browse files Browse the repository at this point in the history
Add cookie param in luckyframework
  • Loading branch information
hahwul authored Nov 22, 2023
2 parents 1323a9c + c0c0060 commit ee39988
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ class Api::SignUps::Create < ApiAction

post "/api/sign_ups" do
user = SignUpUser.create!(params)
cookies.get("name1")
cookies["name2"]

json({token: UserToken.generate(user)})
end
end
5 changes: 4 additions & 1 deletion spec/functional_test/testers/crystal_lucky_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ extected_endpoints = [
Param.new("X-Forwarded-For", "", "header"),
]),
Endpoint.new("/api/sign_ins", "POST", [Param.new("users", "", "json")]),
Endpoint.new("/api/sign_ups", "POST"),
Endpoint.new("/api/sign_ups", "POST", [
Param.new("name1", "", "cookie"),
Param.new("name2", "", "cookie"),
]),
]

FunctionalTester.new("fixtures/crystal_lucky/", {
Expand Down
10 changes: 10 additions & 0 deletions src/analyzer/analyzers/analyzer_crystal_lucky.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ class AnalyzerCrystalLucky < Analyzer
return Param.new(param, "", "header")
end

if content.includes? "cookies.get("
param = content.split("cookies.get(")[1].split(")")[0].gsub("\"", "").gsub("'", "")
return Param.new(param, "", "cookie")
end

if content.includes? "cookies["
param = content.split("cookies[")[1].split("]")[0].gsub("\"", "").gsub("'", "")
return Param.new(param, "", "cookie")
end

Param.new("", "", "")
end

Expand Down

0 comments on commit ee39988

Please sign in to comment.