Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse noteId method #6

Open
Yukaii opened this issue Jun 24, 2020 · 1 comment
Open

Parse noteId method #6

Yukaii opened this issue Jun 24, 2020 · 1 comment

Comments

@Yukaii
Copy link
Member

Yukaii commented Jun 24, 2020

The noteId of history object returned from history API might be malformed. We need to provide at least one utility function to parse note id.

@StephLin
Copy link

StephLin commented Jul 6, 2020

I think regular expression might be a way to handle the node id for history:

function getNoteId(payload: String) {
  const regex = /^(s\/|c\/|p\/)?(?<id>(@[A-Za-z0-9\_\-]+\/)?[A-Za-z0-9\-\_]+).*$/;
  const noteId = payload.replace(regex, '$<id>');
  return noteId;
}

However it does not handle pages under book mode. In fact it only parse the note id of that book.
How do you think @Yukaii ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants