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

Fix redirects #48915

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/createHelpRedirects.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Adds new routes to the Cloudflare Bulk Redirects list for communityDot to helpDot
# pages. Does some basic sanity checking.
# pages. Sanity checking is done upstream in the PRs themselves in verifyRedirect.sh.

set -e

Expand Down
28 changes: 16 additions & 12 deletions .github/scripts/verifyRedirect.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#!/bin/bash

# HelpDot - Verifies that redirects.csv does not have any duplicates
# Duplicate sourceURLs break redirection on cloudflare pages
# HelpDot - Verifies that redirects.csv does not have any errors that would prevent
# the bulk redirects in Cloudflare from working. This includes:
# Duplicate sourceURLs
# Source URLs containing anchors or URL params
# URLs pointing to themselves
#
# We also prevent adding source or destination URLs outside of an allowed list
# of domains. That's because these redirects run on our zone as a whole, so you
# could add a redirect for sites outside of help/community and Cloudflare would allow it
# and it would work.

source scripts/shellUtils.sh

declare -r REDIRECTS_FILE="docs/redirects.csv"
declare -a ITEMS_TO_ADD

declare -r RED='\033[0;31m'
declare -r GREEN='\033[0;32m'
declare -r NC='\033[0m'

duplicates=$(awk -F, 'a[$1]++{print $1}' $REDIRECTS_FILE)
if [[ -n "$duplicates" ]]; then
echo "${RED}duplicate redirects are not allowed: $duplicates ${NC}"
echo "${RED}duplicate redirects are not allowed: $duplicates ${RESET}"
exit 1
fi

npm run detectRedirectCycle
DETECT_CYCLE_EXIT_CODE=$?
if [[ DETECT_CYCLE_EXIT_CODE -eq 1 ]]; then
echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${NC}"
echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${RESET}"
exit 1
fi

Expand All @@ -46,8 +50,8 @@ while read -r line; do

# Basic sanity checking to make sure that the source and destination are in expected
# subdomains.
if ! [[ $SOURCE_URL =~ ^https://(community|help)\.expensify\.com ]] || [[ $SOURCE_URL =~ \# ]]; then
error "Found source URL that is not a communityDot or helpDot URL, or contains a '#': $SOURCE_URL"
if ! [[ $SOURCE_URL =~ ^https://(community|help)\.expensify\.com ]] || [[ $SOURCE_URL =~ (\#|\?) ]]; then
error "Found source URL that is not a communityDot or helpDot URL, or contains a '#' or '?': $SOURCE_URL"
exit 1
fi

Expand All @@ -66,9 +70,9 @@ done <<< "$(tail +2 $REDIRECTS_FILE)"
# Sanity check that we should actually be running this and we aren't about to delete
# every single redirect.
if [[ "${#ITEMS_TO_ADD[@]}" -lt 1 ]]; then
error "No items found to add, why are we running?"
error "${RED}No items found to add, why are we running?${RESET}"
exit 1
fi

echo -e "${GREEN}The redirects.csv is valid!${NC}"
echo -e "${GREEN}The redirects.csv is valid!${RESET}"
exit 0
9 changes: 3 additions & 6 deletions docs/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,9 @@ https://community.expensify.com/discussion/8118/how-to-redeem-deel-com-perk,http
https://community.expensify.com/discussion/8256/how-to-redeem-25-off-slack-with-the-expensify-card,https://help.expensify.com/articles/expensify-classic/expensify-card/Expensify-Card-Perks#slack
https://community.expensify.com/discussion/8737/exclusive-perks-for-expensify-card-members,https://help.expensify.com/articles/expensify-classic/expensify-card/Expensify-Card-Perks
https://community.expensify.com/discussion/9040/how-to-redeem-10-off-netsuite-with-the-expensify-card,https://help.expensify.com/articles/expensify-classic/expensify-card/Expensify-Card-Perks#netsuite
https://community.expensify.com/discussion/4828/how-to-match-your-company-cards-statement-to-expensify/p1?new=1,https://help.expensify.com/articles/expensify-classic/connect-credit-cards/company-cards/Reconciliation
https://community.expensify.com/discussion/4828/how-to-match-your-company-cards-statement-to-expensify,https://help.expensify.com/articles/expensify-classic/connect-credit-cards/company-cards/Reconciliation
https://community.expensify.com/discussion/5580/deep-dive-configure-advanced-settings-for-netsuite/,https://help.expensify.com/articles/expensify-classic/connections/netsuite/Configure-Netsuite#step-3-configure-advanced-settings
https://community.expensify.com/discussion/7231/how-to-export-invoices-to-netsuite/p1?new=1,https://help.expensify.com/articles/expensify-classic/connections/netsuite/Configure-Netsuite#export-invoices
https://community.expensify.com/discussion/7231/how-to-export-invoices-to-netsuite/,https://help.expensify.com/articles/expensify-classic/connections/netsuite/Configure-Netsuite#export-invoices
https://community.expensify.com/discussion/9168/how-to-troubleshoot-general-errors-when-uploading-your-id-via-onfido,https://help.expensify.com/articles/new-expensify/expenses-&-payments/Resolve-Errors-Adding-a-Bank-Account
https://community.expensify.com/discussion/4707/how-to-set-up-your-mobile-app/,https://use.expensify.com/expensify-mobile-app
https://community.expensify.com/discussion/7066/introducing-concierge-travel,https://help.expensify.com/expensify-classic/hubs/travel/
Expand All @@ -554,7 +554,6 @@ https://help.expensify.com/articles/expensify-classic/expensify-card/Set-Up-the-
https://community.expensify.com/discussion/5542/deep-dive-what-are-ereceipts,https://help.expensify.com/articles/expensify-classic/workspaces/Expense-Settings#ereceipts
https://community.expensify.com/discussion/5738/deep-dive-how-does-concierge-receipt-audit-work,https://help.expensify.com/articles/expensify-classic/workspaces/Expense-Settings#concierge-receipt-audit
https://community.expensify.com/discussion/4643/how-to-invite-people-to-your-policy-using-a-join-link,https://help.expensify.com/articles/expensify-classic/workspaces/Invite-members-and-assign-roles#invite-with-a-link
https://community.expensify.com/discussion/4975/how-to-invite-users-to-your-policy-manually-or-in-bulk/p1?new=1,https://help.expensify.com/articles/expensify-classic/workspaces/Invite-members-and-assign-roles
https://help.expensify.com/articles/expensify-classic/workspaces/Invoicing,https://help.expensify.com/articles/expensify-classic/workspaces/Set-Up-Invoicing
https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/bank-accounts/Enable-Global-Reimbursements.md,https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/bank-accounts/Enable-Global-Reimbursements
https://help.expensify.com/articles/expensify-classic/integrations/travel-integrations/Trip-Actions,https://help.expensify.com/expensify-classic/hubs/connections/
Expand All @@ -565,8 +564,6 @@ https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments
https://help.expensify.com/articles/expensify-classic/connect-credit-cards/Global-Reimbursements,https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/bank-accounts/Enable-Global-Reimbursements
https://community.expensify.com/discussion/4641/how-to-add-a-deposit-only-bank-account-both-personal-and-business,https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/bank-accounts/Connect-US-Business-Bank-Account
https://community.expensify.com/discussion/5940/how-to-get-reimbursed-outside-the-us-with-wise-for-non-us-employees,https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/Third-Party-Payments
https://community.expensify.com/home/leaving?allowTrusted=1&target=https%3A%2F%2Fqbo.intuit.com%2Fapp%2Fvendors,https://help.expensify.com/articles/expensify-classic/connections/quickbooks-online/Quickbooks-Online-Troubleshooting
https://community.expensify.com/discussion/5654/deep-dive-using-expense-rules-to-vendor-match-when-exporting-to-an-accounting-package/p1?new=1,https://help.expensify.com/articles/expensify-classic/connections/xero/Xero-Troubleshooting
https://help.expensify.com/articles/expensify-classic/spending-insights/(https://help.expensify.com/articles/expensify-classic/spending-insights/Custom-Templates),https://help.expensify.com/articles/expensify-classic/spending-insights/Custom-Templates
https://help.expensify.com/articles/expensify-classic/spending-insights,https://help.expensify.com/articles/expensify-classic/spending-insights/Custom-Templates
https://help.expensify.com/articles/expensify-classic/settings/account-settings/Set-notifications,https://help.expensify.com/articles/expensify-classic/settings/account-settings/Set-Notifications
https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/payments/Reimburse-Reports-Invoices-and-Bills,https://help.expensify.com/articles/expensify-classic/bank-accounts-and-payments/payments/Reimburse-Reports
Loading