Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Create extension to trim url #12928

Closed

Conversation

sarah541
Copy link
Contributor

@sarah541 sarah541 commented Oct 11, 2022

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
  • Breaking Changes: If this is a breaking change, please push a draft PR on Reference Browser to address the breaking issues.

GitHub Automation

Fixes #12804
Fixes #12930

@sarah541 sarah541 requested a review from Amejia481 October 11, 2022 17:54
@sarah541 sarah541 requested a review from a team as a code owner October 11, 2022 17:54
// https://github.com/mozilla-mobile/android-components/issues/5249
const val MAX_URI_LENGTH = 25000

fun getTrimmedUrl(url: String): String {
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if this should be moved to one of our more generic support components since this is being used more widely outside this browser-toolbar component. One idea is support-ktx https://searchfox.org/mozilla-mobile/source/android-components/components/support/ktx/src/main/java/mozilla/components/support/ktx/kotlin/String.kt

We also want to make this an actual extension of Strings

Suggested change
fun getTrimmedUrl(url: String): String {
fun String.toTrimmedUrl(): String {

Copy link
Member

Choose a reason for hiding this comment

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

Also, please add a kDoc

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was kinda looking for this. Thank you!

Seems like ktlint complains about all existing problems in the touched files.
Building on Windows with the git config `core.autocrlf=true` (sorry)
results in a line ending of `\r\n` in `version.txt`, so just removing
`\n` leaves trailing whitespace in the resulting Java code that ends
in a build failure.
@@ -9,7 +9,7 @@ object Gecko {
/**
* GeckoView Version.
*/
const val version = "107.0.20221011093208"
const val version = "107.0.20221012094509"
Copy link
Contributor

@Amejia481 Amejia481 Oct 12, 2022

Choose a reason for hiding this comment

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

nit: Looks like it was committed by mistake :)

@@ -51,11 +51,19 @@ class AppLinksUseCases(
private val launchInApp: () -> Boolean = { false },
private val alwaysDeniedSchemes: Set<String> = ALWAYS_DENY_SCHEMES
) {
@Suppress("QueryPermissionsNeeded") // We expect our browsers to have the QUERY_ALL_PACKAGES permission
@Suppress(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Looks like unrelated changes

Comment on lines +84 to +85
<!-- Title of the time picker dialog. -->
<string name="mozac_feature_prompts_set_time">Set time</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +84 to +85
accountManager.unregisterForSyncEvents(eventObserver)
accountManager.unregister(accountObserver)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +298 to +304

/**
* Returns truncated urls and search terms to improve performance.
*/
fun String.toTrimmedUrl(): String {
return this.take(MAX_URI_LENGTH)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏽

@Amejia481
Copy link
Contributor

I think we will need to rebase as there are some unrelated changes that have been leaked to the PR :)

@sarah541 sarah541 closed this Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
7 participants