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 #2539: Super Referrer Improvements (Clipboard) #2535
Merged
+157
−17
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7101d33
Added support for pre-determined / binary related ref codes.
jhreis 646e5bd
Clipboard processing added.
jhreis 2359577
Merge branch 'development' into referral_fixes
jhreis 624dabc
Clear clipboard after successful ref promo read.
jhreis 15bfead
Cleaned up code a bit, no functional changes.
jhreis 6fdb085
Added ref code validation.
jhreis 8214d99
Changed ref code sanitzation to use regex.
jhreis 285fe1e
Added unit tests for ref code sanitization.
jhreis aaa762e
Removed unnecessary comment.
jhreis 3ce30ea
Merge branch 'development' into referral_fixes
jhreis 16d5037
Added path components helper to avoid manually adding forward slashes.
jhreis 576ae4a
Comment cleanup.
jhreis 834a1fc
Fixed crash from bad referral situation.
jhreis 98253b6
Fixed S3 bucket endpoint for enterprise builds.
jhreis ade056f
Merge branch 'development' into referral_fixes
jhreis 17f0717
Merge branch 'development' into referral_fixes
jhreis File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Added ref code validation.
- Loading branch information
| @@ -194,13 +194,28 @@ public class UserReferralProgram { | ||
| /// Uses very strict matching. | ||
| /// Returns the sanitized code, or nil if no code was found | ||
| public class func sanitize(input: String?) -> String? { | ||
| guard var input = input, input.hasPrefix(self.clipboardPrefix) else { return nil } | ||
| guard var code = input, code.hasPrefix(self.clipboardPrefix) else { return nil } | ||
|
|
||
| // +1 to strip off `:` that proceeds the defined prefix | ||
| input.removeFirst(self.clipboardPrefix.count + 1) | ||
| code.removeFirst(self.clipboardPrefix.count + 1) | ||
| // Add any other potential validation here, e.g. validating the actual ref code string | ||
|
This conversation was marked as resolved
by jhreis
BrendanEich
Member
|
||
| return input.isEmpty ? nil : input | ||
| if code.count != 6 { return nil } | ||
| let letters = code.prefix(3) | ||
| let numbers = code.suffix(3) | ||
|
|
||
| // Cannot use `isLetters` or `isUppercase` b/inc Æ and the like | ||
| let validLetters = letters.allSatisfy(("A"..."Z").contains) | ||
|
|
||
| // Cannot use `isNumber` b/inc 万 and the like | ||
| let validNumbers = numbers.allSatisfy(("0"..."9").contains) | ||
|
|
||
| // Both conditions must be met | ||
| return validLetters && validNumbers ? code : nil | ||
|
|
||
| // Regex solution | ||
| // let valid = code.range(of: #"\b[A-Z]{3}[0-9]{3}\b"#, options: .regularExpression) != nil // true | ||
| } | ||
|
|
||
| /// Same as `customHeaders` only blocking on result, to gaurantee data is available | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
https://docs.google.com/document/d/15oSBC-57OpLO3pZK_XjHa1SwIjnjuxA8Wi74K5ZaxPc/edit?disco=AAAAJWaIrNI -
[0-9A-Z]{6}should work