Open
Description
openedon Dec 1, 2023
Describe the bug
A clear and concise description of what the bug is.
Currently on iOS we check if Identifier is a valid UUID (done automatically by NSUUID object).
However on Android we just use raw string value. We can check if it's a valid MAC address as well.
How to fix, some ideas from @Daeda88
private val regex = "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$".toRegex()
fun main() {
println("3D:F2:C9:A6:B3:4F".asValidIdentifier())
}
private fun String.asValidIdentifier(): String? = if (regex.matches(this)) {
this
} else {
null
}
or
private fun String.asValidIdentifier(): String? = regex.matchEntire(this)?.let {
it.groupValues[0]
}
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
Add any other context about the problem here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels