refactor(landing): refine the labels param parsing logic #3413
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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
While looking through the
basemaps/landing
package, I noticed that the code for handling thelabels
URL query parameter is hard to understand. The default behavior is also unclear. This work aims to fix that.Modifications
Modified the code responsible for parsing the
labels
URL query parameter. The code lives within the updateFromUrl function. A 'before' and 'after' is as follows:Before
The current logic, although concise, is a little difficult to interpret:
After
The updated logic, although verbose, seeks to clarify the process flow and explain each statement's context:
Expanded upon some of the existing test cases that validate the parsing logic for the
labels
URL query parameter.Verification
All of the original and adjusted test cases pass, indicating that the parsing logic remains unchanged.