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

Fix small util bugs #1871

Merged
merged 2 commits into from Oct 14, 2020
Merged

Fix small util bugs #1871

merged 2 commits into from Oct 14, 2020

Conversation

Twixes
Copy link
Collaborator

@Twixes Twixes commented Oct 14, 2020

Changes

Small but impactful bugs caused by migration to TS.

@timgl timgl temporarily deployed to posthog-fixes-xrr2bskqbv1nxpvr October 14, 2020 09:30 Inactive
@Twixes Twixes temporarily deployed to posthog-fixes-xrr2bskqbv1nxpvr October 14, 2020 09:38 Inactive
const regex = new RegExp(expression)
return !!string.match(regex)
const regexp = /^\s*https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi
return !!string.match?.(regexp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why do we need the ?? In this context string is not null right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would always be a string, but I made a small mistake in this func when moving the file from JS to TS, by removing this check that some JS, non-type respecting parts of the codebase relied on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the signature is lying (this is called with null/undefined) I'd say it's also worth updating the method signature.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Twixes, I agree with @macobo here! If the argument with the name string can be either a string, undefined or null, we should specify all the options in the function signature.

@Twixes Twixes merged commit 19adefc into master Oct 14, 2020
@Twixes Twixes deleted the fixes branch October 14, 2020 10:00
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

Successfully merging this pull request may close these issues.

None yet

4 participants