Skip to content

allow numbers in reddit post_id #1030

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

Merged
merged 1 commit into from
Jul 22, 2022
Merged

allow numbers in reddit post_id #1030

merged 1 commit into from
Jul 22, 2022

Conversation

swoker
Copy link
Contributor

@swoker swoker commented Jul 18, 2022

Description

Reddit Threads can have numbers in them, so the regex should allow that

Issue Fixes

None

Checklist:

  • I am pushing changes to the develop branch
  • I am using the recommended development environment
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have formatted and linted my code using python-black and pylint
  • I have cleaned up unnecessary files
  • My changes generate no new warnings
  • My changes follow the existing code-style
  • My changes are relevant to the project

Any other information (e.g how to test the changes)

None

@JasonLovesDoggo
Copy link
Collaborator

The checker just checked against URIs...

@@ -13,7 +13,7 @@ random = { optional = true, options = [true,
false,
], default = false, type = "bool", explanation = "If set to no, it will ask you a thread link to extract the thread, if yes it will randomize it. Default: 'False'", example = "True" }
subreddit = { optional = false, regex = "[_0-9a-zA-Z]+$", nmin = 3, explanation = "what subreddit to pull posts from, the name of the sub, not the URL", example = "AskReddit", oob_error = "A subreddit name HAS to be between 3 and 20 characters" }
post_id = { optional = true, default = "", regex = "^((?!://|://)[+a-zA-Z])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }
post_id = { optional = true, default = "", regex = "^((?!://|://)[+a-zA-Z0-9])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just \w?

Suggested change
post_id = { optional = true, default = "", regex = "^((?!://|://)[+a-zA-Z0-9])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }
post_id = { optional = true, default = "", regex = "^((?!://|://)[+\w])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/w would allow _ as well, which cannot be part of a post_id

Copy link
Contributor

Choose a reason for hiding this comment

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

good point, what about this?

Suggested change
post_id = { optional = true, default = "", regex = "^((?!://|://)[+a-zA-Z0-9])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }
post_id = { optional = true, default = "", regex = "^((?!://|://)[+\w][^_])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could work, but imho a-zA-Z0-9 is much easier to read

@efa2d19
Copy link
Contributor

efa2d19 commented Jul 20, 2022

The checker just checked against URIs...

Yeah, there is negative lookahead for :// but it won't match if there are numbers in id
I noticed that problem , there can be numbers in id, for example, w35ocq

Copy link
Contributor

@efa2d19 efa2d19 left a comment

Choose a reason for hiding this comment

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

👍🏻

@JasonLovesDoggo JasonLovesDoggo merged commit 12f99f4 into elebumm:develop Jul 22, 2022
@swoker swoker deleted the patch-2 branch July 22, 2022 14:41
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.

3 participants