How to secure a dynamic page from unauthorised access

Any ideas how to extract the last 8 characters from the URL? I thought wixLocation.path might give me this?

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady(function () {
 let path = wixLocation.path;
 if (wixUsers.currentUser.loggedIn) {
                wixData.query("Members/PrivateMembersData")
                    .eq("_id", wixUsers.currentUser.id)
                    .find()
                    .then((results) => {
                        var studno = results.items[0].nickname;
                        if (path === studno) {
                                $w('#StudentNo').show();
                                $w('#StudentName').show();
                                $w('#InterimGrade').show();
                                $w('#SecondGrade').show();
                                $w('#FinalGrade').show();
                                $w('#Feedback').show();

                            }})}});