File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,5 @@ proc isInt*(s: cstring): bool {.asmNoStackFrame.} =
31
31
32
32
proc parseInt * (s: cstring ): int {.importcpp : " parseInt(#, 10)" , nodecl .}
33
33
proc parseFloat * (s: cstring ): BiggestFloat {.importc , nodecl .}
34
+
35
+ proc join * (a: openArray [cstring ], sep = cstring " " ): cstring {.importcpp : " (#.join(#))" , nodecl .}
Original file line number Diff line number Diff line change 27
27
type
28
28
RouterData * = ref object # # information that is passed to the 'renderer' callback
29
29
hashPart* : cstring # # the hash part of the URL for routing.
30
+ queryString* : cstring # # The search string, can be used for passing data to karax
30
31
31
32
KaraxInstance * = ref object # # underlying karax instance. Usually you don't have
32
33
# # know about this.
@@ -637,6 +638,7 @@ proc runDiff*(kxi: KaraxInstance; oldNode, newNode: VNode) =
637
638
638
639
var onhashChange {.importc : " window.onhashchange" .}: proc ()
639
640
var hashPart {.importc : " window.location.hash" .}: cstring
641
+ var queryString {.importc : " window.location.search" .}: cstring
640
642
641
643
proc avoidDomDiffing * (kxi: KaraxInstance = kxi) =
642
644
# # enforce a full redraw for the next redraw operation.
@@ -660,8 +662,16 @@ proc dodraw(kxi: KaraxInstance) =
660
662
return
661
663
662
664
kxi.rendering = true
663
-
664
- let rdata = RouterData (hashPart: hashPart)
665
+
666
+ var rdata = RouterData ()
667
+ if cstring " ?" in hashPart:
668
+ let hashSplit = hashPart.split (cstring " ?" )
669
+ rdata.hashPart = hashSplit[0 ]
670
+ rdata.queryString = join (hashSplit[1 ..^ 1 ], cstring " ?" )
671
+ else :
672
+ rdata.hashPart = hashPart
673
+ rdata.queryString = queryString
674
+
665
675
let newtree = kxi.renderer (rdata)
666
676
inc kxi.runCount
667
677
newtree.id = kxi.rootId
You can’t perform that action at this time.
0 commit comments