mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-06 11:47:47 +02:00
* Add easy access method RouteFromURL
This commit is contained in:
parent
6ba4e00741
commit
e6d18fc1b4
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user