Skip to content

Bugfix FXIOS-12033 [SEC] Fix check for {searchTerms} in base URL #26223

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

Merged
merged 3 commits into from
Apr 24, 2025

Conversation

mattreaganmozilla
Copy link
Collaborator

📜 Tickets

Jira ticket
Github issue

💡 Description

Fixes an issue with checks for {searchTerm} in the base URL of our AS-based search engines. It turns out the API headers did, in fact, contain a typo.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@mattreaganmozilla mattreaganmozilla requested a review from a team as a code owner April 21, 2025 20:49
@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Apr 21, 2025

Messages
📖 Project coverage: 35.53%
📖 Edited 2 files
📖 Created 0 files

Client.app: Coverage: 34.93

File Coverage
ASSearchEngineUtilities.swift 73.53%

Generated by 🚫 Danger Swift against 33d2adc

@mattreaganmozilla mattreaganmozilla force-pushed the mr/12033 branch 2 times, most recently from 9e5ad84 to df0c1de Compare April 22, 2025 18:35
Copy link
Contributor

@cyndichin cyndichin left a comment

Choose a reason for hiding this comment

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

thanks @mattreaganmozilla! mainly nits and some comments to clarify since I haven't been too close in this area.

@@ -46,11 +46,13 @@ struct ASSearchEngineUtilities {
return URLQueryItem(name: $0.name, value: value)
}
// From API docs: "This may be skipped if `{searchTerm}` is included in the base."
if let searchArg = searchURL.searchTermParamName, !searchURL.base.contains("{searchTerm}") {
// Note: term vs terms is not a typo.
// Note: there is a typo in the docs, the value is searchTerms (plural).
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we reference the docs? not sure where the typo was. Or we can add a JIRA ticket number here with more context.

Also interesting to see that the previous comment says:
// Note: term vs terms is not a typo. Do you have context on this 🤔 or seems like this was a mistake?

Copy link
Collaborator Author

@mattreaganmozilla mattreaganmozilla Apr 24, 2025

Choose a reason for hiding this comment

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

The short version is that I was going by the docs we had and that was the origin of the first comment. But I double-checked the data eventually (and then checked with AS team) and it turned out the docs were wrong. Those headers are being fixed, but I wanted to be sure to document which version (searchTerm vs searchTerms) was correct.

@@ -10,6 +10,59 @@ import WebKit
import MozillaAppServices

class ASSearchEngineUtilitiesTests: XCTestCase {
private let leo_eng_deu_engine_no_search_params =
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥 thanks for adding tests!

Comment on lines +163 to +164
let expected = "https://dict.leo.org/englisch-deutsch/{searchTerms}"
XCTAssertEqual(result, expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

curious, how come we include searchTerms if we don't have search params?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The additional parameters are for things besides the search parameters themselves (they're for additional arguments like the client or partner code identifier, etc.). So it's valid to have a search URL without them.

@mattreaganmozilla mattreaganmozilla merged commit 905d329 into mozilla-mobile:main Apr 24, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants