My active class stopped working after I added a slash before my href links **(href="/link")**, it works if I remove it **(href="link")**, can anyone suggest a solution?

My working script without slash:

```
$(function() {
            $('nav a[href^="' + location.pathname.split("/")[1] + '"]').addClass('active');
        });

```

My blade file

```
<nav class="mt-2">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
                        data-accordion="false">
                        <!-- Add icons to the links using the .nav-icon class
                        with font-awesome or any other icon font library -->
                        <li class="nav-item">
                            <a href="/home" class="nav-link">
                                <i class="nav-icon fas fa-tachometer-alt"></i>
                                <p>
                                    Dashboard
                                </p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="/investment" class="nav-link">
                                <i class="nav-icon fas fa-rupee-sign"></i>
                                <p>
                                    Investments
                                </p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="/investor" class="nav-link">
                                <i class="nav-icon fas fa-user"></i>
                                <p>
                                    Investors
                                </p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="/product" class="nav-link">
                                <i class="nav-icon fas fa-shopping-cart"></i>
                                <p>
                                    Products
                                </p>
                            </a>
                        </li>
                    </ul>
                </nav>

```