Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Frontend</title>
- </head>
- <body>
- <h1 id="route">Current route: </h1>
- <script>
- // Base URL under which the frontend SPA is running
- const baseUrl = '/view';
- // Get complete path after the hostname + port
- const pathname = location.pathname;
- // Determine current route, by removing the base URL from the path name
- const currentRoute = pathname.replace(new RegExp('^' + baseUrl), '');
- // Output route
- const header = document.getElementById('route');
- header.innerText += currentRoute;
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement