From e6d18fc1b4ff071b03e706a898fc982a116b0fdc Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 23 Mar 2020 13:52:15 +0000 Subject: [PATCH] * Add easy access method RouteFromURL --- packages/rtl/webrouter.pp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/rtl/webrouter.pp b/packages/rtl/webrouter.pp index 3d57dd3..92c2eae 100644 --- a/packages/rtl/webrouter.pp +++ b/packages/rtl/webrouter.pp @@ -258,6 +258,8 @@ Type Function RouteRequest(Const ARouteURL : String; DoPush : Boolean = False) : TRoute; // Extract request path from URL. By default, returns the URL function GetRequestPath(const URL: String): String; virtual; + // Examine the URL hash and route the request. Returns the route. Use when arriving on a page do handle the initial route + Function RouteFromURL : String; // Navigation. These are easy-access methods for history. function GetCurrentLocation: String; // These use the history mechanism @@ -644,6 +646,16 @@ begin Result:=SanitizeRoute(URL); end; +function TRouter.RouteFromURL: String; + +begin + // Result:=Copy(window.location.hash,2,Length(window.location.hash)-1); + // Writeln('Curr ', GetCurrentLocation,' route : ',Result); + Result:=GetCurrentLocation; + if (Result<>'') then + Router.RouteRequest(Result,true); +end; + function TRouter.GetCurrentLocation: String; begin Result:=History.GetCurrentLocation;