<commit_before>import * as PH from "../";

export function parseUrl(fullUrl: string): PH.Path.PathDetails {
  let path: PH.Path.PathDetails = {};

  // split path
  PH.Assert.isTrue(fullUrl.substr(0, 1) == "/", "Url doesn't start with /");
  let url = fullUrl.toLowerCase().substr(1);
  if (url.endsWith("/"))  // ignore "/" on end
    url = url.substr(0, url.length - 1);
  let split = url.split("/");

  // pages not related to workspace
  let part = split[0];
  if ((part == "" && split.length == 1)
    || (part == "i" && split.length >= 2)) {   // Instance and Todo-links are handled on StartPage
    path.page = PH.Path.Page.StartPage;
    return path;
  } else if (part == "signin" && split.length == 1) {
    path.page = PH.Path.Page.SigninPage;
    return path;
  } else if (part == "signup" && split.length == 1) {
    path.page = PH.Path.Page.SignupPage;
    return path;
  } else if (part == "library" && split.length == 1) {
    path.page = PH.Path.Page.LibraryPage;
    return path;
  } else if (!part.startsWith("@")) {
    // ...otherwise workspace must follow
    return null;
  }

  // -> Workspace  
  path.workspaceUrlName = part.substr(1);

  part = (split.length >= 2 ? split[1] : PH.Workspace.WorkspaceView.Processes);
  if (PH.Workspace.isValidWorkspaceView(part) && split.length <= 2) {
    path.page = PH.Path.Page.WorkspacePage;
    path.view = <PH.Workspace.WorkspaceView>part;
    return path;
  } else if (part == PH.Process.ProcessView.NewProcess) {
    path.page = PH.Path.Page.ProcessPage;
    path.view = <PH.Process.ProcessView>part;
    return path;
  } else if (part != "p" || split.length < 3) {
    // ...otherwise process must follow
    return null;
  }

  // -> Process
  path.processUrlName = decodeURIComponent(split[2]);

  part = (split.length >= 4 ? split[3] : PH.Process.ProcessView.Show);
  if (PH.Process.isValidProcessView(part) && split.length <= 4) {
    path.page = PH.Path.Page.ProcessPage;
    path.view = <PH.Process.ProcessView>part;
    return path;
  }

  return path;
} 

export function parseNotificationLink(fullUrl: string): PH.Path.NotificationLinkElements {
  let elements: PH.Path.NotificationLinkElements = {};
  
  // split path
  PH.Assert.isTrue(fullUrl.substr(0, 1) == "/", "Url doesn't start with /");<commit_msg>fix: invalid tab names did not show error<commit_after>import * as PH from "../";

export function parseUrl(fullUrl: string): PH.Path.PathDetails {
  let path: PH.Path.PathDetails = {};

  // split path
  PH.Assert.isTrue(fullUrl.substr(0, 1) == "/", "Url doesn't start with /");
  let url = fullUrl.toLowerCase().substr(1);
  if (url.endsWith("/"))  // ignore "/" on end
    url = url.substr(0, url.length - 1);
  let split = url.split("/");

  // pages not related to workspace
  let part = split[0];
  if ((part == "" && split.length == 1)
    || (part == "i" && split.length >= 2)) {   // Instance and Todo-links are handled on StartPage
    path.page = PH.Path.Page.StartPage;
    return path;
  } else if (part == "signin" && split.length == 1) {
    path.page = PH.Path.Page.SigninPage;
    return path;
  } else if (part == "signup" && split.length == 1) {
    path.page = PH.Path.Page.SignupPage;
    return path;
  } else if (part == "library" && split.length == 1) {
    path.page = PH.Path.Page.LibraryPage;
    return path;
  } else if (!part.startsWith("@")) {
    // ...otherwise workspace must follow
    return null;
  }

  // -> Workspace  
  path.workspaceUrlName = part.substr(1);

  part = (split.length >= 2 ? split[1] : PH.Workspace.WorkspaceView.Processes);
  if (PH.Workspace.isValidWorkspaceView(part) && split.length <= 2) {
    path.page = PH.Path.Page.WorkspacePage;
    path.view = <PH.Workspace.WorkspaceView>part;
    return path;
  } else if (part == PH.Process.ProcessView.NewProcess) {
    path.page = PH.Path.Page.ProcessPage;
    path.view = <PH.Process.ProcessView>part;
    return path;
  } else if (part != "p" || split.length < 3) {
    // ...otherwise process must follow
    return null;
  }

  // -> Process
  path.processUrlName = decodeURIComponent(split[2]);

  part = (split.length >= 4 ? split[3] : PH.Process.ProcessView.Show);
  if (PH.Process.isValidProcessView(part) && split.length <= 4) {
    path.page = PH.Path.Page.ProcessPage;
    path.view = <PH.Process.ProcessView>part;
    return path;
  } else
    return null;
} 

export function parseNotificationLink(fullUrl: string): PH.Path.NotificationLinkElements {
  let elements: PH.Path.NotificationLinkElements = {};
  
  // split path
  PH.Assert.isTrue(fullUrl.substr(0, 1) == "/", "Url doesn't start with /");
{'fraction_non_alphanumeric': 0.16695614415979157, 'fraction_numerical': 0.009552757273122015, 'mean_word_length': 3.055457746478873, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '621532', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1541, 'n_words': 362}