Skip to content
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

usagov-2077-usps-api-error: update code to remove specail characters … #2121

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

developer43
Copy link
Contributor

…from the address

Jira Task

https://cm-jira.usa.gov/browse/USAGOV-2077

Description

Update logic to remove special characters in the address field before submitting to the USPS API

Type of Changes

  • New Feature
  • Bugfix
  • Frontend (Twig, Sass, JS)
    • Add screenshot showing what it should look like
  • Drupal Config (requires "drush cim")
  • New Modules (requires rebuild)
  • Documentation
  • Infrastructure
    • CMS
    • WAF
    • WWW
    • Egress
    • Tools
    • Cron
  • Other

Testing Instructions

Change Requirements

  • Requires New Documentation (Link: {})
  • Requires New Config
  • Requires New Content

Validation Steps

Screenshot 2024-12-13 at 10 08 34 AM
  • After submitting the address you should see the result without the special character in the address
Screenshot 2024-12-13 at 10 09 29 AM
  • You SHOULD NOT see the xml error
Screenshot 2024-12-13 at 10 10 44 AM Screenshot 2024-12-13 at 10 16 41 AM

Screenshot 2024-12-13 at 10 16 45 AM

Screenshot 2024-12-13 at 10 16 48 AM

Security Review

  • Adds/updates software (including a library or Drupal module)
  • Communication with external service
  • Changes permissions or workflow
  • Requires SSPP updates

Reviewer Reminders

  • Reviewed code changes
  • Reviewed functionality
  • Security review complete or not required

Post PR Approval Instructions

Follow these steps as soon as you merge the new changes.

  1. Go to the USAGov Circle CI project.
  2. Find the commit of this pull request.
  3. Build and deploy the changes.
  4. Update the Jira ticket by changing the ticket status to Review in Test and add a comment. State whether the change is already visible on cms-dev.usa.gov and beta-dev.usa.gov, or if the deployment is still in process.

@developer43 developer43 requested a review from akf December 13, 2024 15:19
Copy link
Member

@akf akf left a comment

Choose a reason for hiding this comment

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

This works, but there were some other special characters to test. In the Jira ticket I see:

Test other addresses using special characters like: &, <, >, ", '

It turns out the only one of those that's causing trouble is <.

You could simplify this a little. You don't need to check for # character before doing the replacement. So you could take that "if" statement out and after this:
streetAddress = streetAddress.replace('#', '');
add this:
streetAddress = streetAddress.replace('<', '');

@@ -223,6 +235,14 @@ async function handleFormSubmission() {
const uspsApiResponse = await addressUSPSValidation(streetAddressField.value, cityField.value, stateField.value, zipCodeField.value);
const response = uspsResponseParser(uspsApiResponse, streetAddressField.value, cityField.value, zipCodeField.value);

// This removes the number sign fromt the address field so
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this commented-out code.

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