-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add support for beatmap link parsing #242
base: master
Are you sure you want to change the base?
Conversation
// Checks if the beatmap string contains only numbers or if it's a file path | ||
if (!Regex.IsMatch(beatmap, @"\A\d+\z|\.osu\z")) | ||
{ | ||
string beatmapLinkPattern = @"osu\.ppy\.sh/b.*/\d+\z"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem robust enough, I can name at least 4 ways of easily breaking it:
- Trailing slash
osu.ppy.sh/b/
linksosu.ppy.sh/beatmaps/
links- Inconsistent casing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the point 1, although I don't see a case where it happens if you did copy and paste the beatmap link from the browser URL bar or from in-game.
I don't understand the point 2 and 3, as from my tests, osu.ppy.sh/b/
and osu.ppy.sh/beatmaps/
links work on my current implementation.
You're right about point 4, I didn't consider casing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I misread the regex, 2 and 3 are indeed supported my bad. Would still prefer a more robust check though, because a completely incorrect link like osu.ppy.sh/boop/123
might match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I made the regex only match osu.ppy.sh/beatmapsets
/b
/beatmaps
links, would it be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, assuming we're talking just about the matching here. Other regex-related comments still apply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's only about the beatmap link match. I'll fix the other issues too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
private void calculate() | ||
private void checkBeatmapIdAndCalculate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for self: this (and a lot of other things) needs to be separated into components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a check that when the input isn't a file or a link it is a valid beatmap id (int.TryParse would be sufficient)
Currently, if you paste a beatmap link into the beatmap ID text box, it just deletes all non-number characters and ends up leaving the beatmapset ID mixed up with the beatmap ID. In this pr, I turned it into an
ExtendedLabelledTextBox
with a regex filter on theSimulateScreen
andBeatmapLeaderboardScreen
classes to check for beatmap links and extracting the correct ID from them.