@labkey/api
    Preparing search index...

    Function getPathFromLocation

    • Parses a location pathname of a LabKey URL into its constituent parts (e.g. controller, action, etc). Defaults to the current location's pathname and context path. The parsed parts of the ActionPath are URI decoded.

      // 1. First example shows the default values as retrieved for the pathname and context path.
      // window.location.pathname = "/labkey/folder/tree/study-participants.view"
      // LABKEY.contextPath = "/labkey"
      const path = ActionURL.getPathFromLocation();

      console.log(path.contextPath); // "/labkey"
      console.log(path.containerPath); // "/folder/tree"
      console.log(path.controller); // "study"
      console.log(path.action); // "participants"

      // 2. Second example when the "pathname" parameter is supplied. The default value for context path is utilized.
      // LABKEY.contextPath = "/labkey"
      const pathname = "/labkey/home/with/folder/project-begin.view";
      const path = ActionURL.getPathFromLocation(pathname);

      console.log(path.contextPath); // "/labkey"
      console.log(path.containerPath); // "/home/with/folder"
      console.log(path.controller); // "project"
      console.log(path.action); // "begin"

      Parameters

      Returns ActionPath