Skip to content

Commit

Permalink
Merge pull request #329 from HapticX/dev
Browse files Browse the repository at this point in the history
release v4.4.4
  • Loading branch information
Ethosa authored Aug 13, 2024
2 parents 99308cd + 2a2c3d1 commit 0d09c58
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion happyx.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

description = "Macro-oriented asynchronous web-framework written with ♥"
author = "HapticX"
version = "4.4.3"
version = "4.4.4"
license = "MIT"
srcDir = "src"
installExt = @["nim"]
Expand Down
2 changes: 1 addition & 1 deletion src/happyx/core/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const
# Framework version
HpxMajor* = 4
HpxMinor* = 4
HpxPatch* = 3
HpxPatch* = 4
HpxVersion* = $HpxMajor & "." & $HpxMinor & "." & $HpxPatch


Expand Down
9 changes: 5 additions & 4 deletions src/happyx/spa/renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,11 @@ template start*(app: App) =
echo "route from ", currentRoute, " to ", r
route(r)
window.addEventListener("hashchange", onHashChangeCallback)
if window.location.hash.len == 0:
route("/")
else:
{.emit : "if(window.location.hash[0]=='#'){`route`(window.location.hash.substr(1));}else{`route`(window.location.hash);}".}
when not defined(disableAutoMove):
if window.location.hash.len == 0:
route("/")
else:
{.emit : "if(window.location.hash[0]=='#'){`route`(window.location.hash.substr(1));}else{`route`(window.location.hash);}".}


macro buildHtml*(root, html: untyped): untyped =
Expand Down
23 changes: 16 additions & 7 deletions src/happyx/ssr/cors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,22 @@ else:
if cors.allowMethods.len > 0:
`headers`["Access-Control-Allow-Methods"] = cors.allowMethods
if cors.allowOrigins.len > 0:
for origin in cors.allowOrigins:
if origin == "*":
`headers`["Access-Control-Allow-Origin"] = `host`
break
elif origin == `host`:
`headers`["Access-Control-Allow-Origin"] = origin
break
if headers.hasKey("origin"):
for origin in cors.allowOrigins:
if origin == "*":
`headers`["Access-Control-Allow-Origin"] = headers["origin"]
break
elif origin == `host`:
`headers`["Access-Control-Allow-Origin"] = origin
break
else:
for origin in cors.allowOrigins:
if origin == "*":
`headers`["Access-Control-Allow-Origin"] = `host`
break
elif origin == `host`:
`headers`["Access-Control-Allow-Origin"] = origin
break
if not `headers`.hasKey("Access-Control-Allow-Origin"):
`headers`["Access-Control-Allow-Origin"] = cors.allowOrigins[0]

Expand Down

0 comments on commit 0d09c58

Please sign in to comment.