-
-
Notifications
You must be signed in to change notification settings - Fork 254
Add custom string input feature to UserAgent api of Butil (#11548) #11549
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 custom string input feature to UserAgent api of Butil (#11548) #11549
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes extend the UserAgent API to accept an optional custom user-agent string parameter. Previously, the API exclusively used the browser's Changes
Sequence DiagramsequenceDiagram
participant UI as UserAgentPage.razor
participant CS as UserAgent.cs
participant TS as userAgent.ts
participant Nav as window.navigator
UI->>CS: Extract(userAgentString?)
CS->>TS: JS interop: extract(userAgentString?)
alt userAgentString provided
TS->>TS: ua = userAgentString
else userAgentString not provided
TS->>Nav: get userAgent
TS->>TS: ua = navigator.userAgent
end
TS->>TS: Parse ua & return properties
TS-->>CS: UserAgentProperties
CS-->>UI: UserAgentProperties
UI->>UI: Log results
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Butil/Bit.Butil/Publics/UserAgent.cs (1)
12-14: Update XML documentation to describe the new parameter.The XML doc comment should document the new
userAgentStringparameter.Apply this diff:
/// <summary> /// Extracts the user agent properties from the browser or web-view. /// </summary> + /// <param name="userAgentString">Optional custom user agent string to parse. If null, uses the browser's navigator.userAgent.</param> [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(UserAgentProperties))]
🧹 Nitpick comments (1)
src/Butil/Demo/Bit.Butil.Demo.Core/Pages/UserAgentPage.razor (1)
27-28: Consider adding a label or placeholder for better UX.The input field lacks context about what the user should enter. Adding a label or placeholder would improve usability and accessibility.
Apply this diff:
-<input @bind="userAgentString" /> +<input @bind="userAgentString" placeholder="Enter custom user agent string (optional)" />Or add a label:
+<label for="userAgentInput">Custom User Agent String (optional):</label> +<input id="userAgentInput" @bind="userAgentString" /> -<input @bind="userAgentString" />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (3)
src/Butil/Bit.Butil/Publics/UserAgent.cs(1 hunks)src/Butil/Bit.Butil/Scripts/userAgent.ts(2 hunks)src/Butil/Demo/Bit.Butil.Demo.Core/Pages/UserAgentPage.razor(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build and test
🔇 Additional comments (3)
src/Butil/Bit.Butil/Scripts/userAgent.ts (2)
8-10: LGTM! The parameter handling logic is sound.The optional parameter with fallback chain (
userAgentString || nav.userAgent || '') correctly prioritizes custom input while maintaining backward compatibility.Note: Whitespace-only strings will be treated as truthy and passed through. This is acceptable for a debugging/testing feature, but consider trimming the input in the UI layer if stricter validation is desired.
426-426: ****src/Butil/Demo/Bit.Butil.Demo.Core/Pages/UserAgentPage.razor (1)
34-40: LGTM! The implementation correctly uses the new parameter.The private field and Extract method implementation properly integrate with the updated UserAgent API.
closes #11548
Summary by CodeRabbit
Release Notes