Skip to content

Commit

Permalink
Merge branch 'main' into 1114-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meissadia authored Jan 29, 2025
2 parents dea48a8 + 020df13 commit 1ebdf75
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 49 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion e2e/pages/shared-lending-platform/Navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ test('Navigation', async ({ page, navigateToFilingHome }) => {
.getByRole('link', { name: 'Diversity & Inclusion' })
.click();
await expect(page.locator('h1')).toContainText(
'Diversity and inclusion at the Bureau',
'Office of Minority and Women Inclusion at the Bureau',
);
await page.goBack();

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 0 additions & 40 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { useQuery } from '@tanstack/react-query';
import { MarkdownText } from 'MarkdownTest';
import { fetchUserProfile } from 'api/requests';
import useSblAuth from 'api/useSblAuth';
import classNames from 'classnames';
import FooterCfGovWrapper from 'components/FooterCfGovWrapper';
import { Link } from 'components/Link';
import { LoadingApp, LoadingContent } from 'components/Loading';
import ScrollToTop from 'components/ScrollToTop';
import { Alert, PageHeader, SkipNav } from 'design-system-react';
Expand Down Expand Up @@ -75,44 +73,6 @@ if (import.meta.env.DEV) {
}
if (!isRoutingEnabled) console.warn('Routing is disabled!');

/**
* Determine if the current provided URL (href) is the current page
* @param href string
* @returns string
*/
const deriveClassname = (href: string): string => {
let cname = 'nav-item';
const pattern = `${href}$`;

const regex = new RegExp(pattern);
if (regex.test(window.location.href)) {
cname += ' selected';
}

return cname;
};

interface NavItemProperties {
className: string;
href: string;
label: string;
}

export function NavItem({
href,
label,
className,
}: NavItemProperties): JSX.Element {
return (
<Link
{...{ href }}
className={classNames(deriveClassname(href), className)}
>
{label}
</Link>
);
}

function BasicLayout(): ReactElement {
const headerLinks = [...useHeaderAuthLinks()];
const location = useLocation();
Expand Down
14 changes: 9 additions & 5 deletions src/components/Link.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ export const isExternalLinkImplied = (targetUrl: string): boolean => {
const internalProtocols = ['mailto:'];
if (internalProtocols.includes(parsed.protocol)) return false;

// Any subdomain of consumerfinance.gov or the current host
const isInternalDomain = new RegExp(
`([\\S]*\\.)?(consumerfinance\\.gov|${window.location.host})`,
).test(parsed.host);
// [Internal] Any subdomain of consumerfinance.gov or the current host
const internalHosts = [
'www.consumerfinance.gov',
'sblhelp.consumerfinance.gov',
window.location.host,
];

const isExternal = !internalHosts.includes(parsed.host);

return !isInternalDomain;
return isExternal;
};

// External link icon w/ spacing
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Filing/FilingApp/FilingSteps.helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { FilingStatusAsNumber } from 'types/filingTypes';
// Does the current browser URL correspond to this Step?
const isStepCurrent = (stepPath: string): boolean => {
const { pathname } = window.location;
const matcher = new RegExp(stepPath);
if (matcher.test(pathname)) return true;
return false;
return pathname.includes(stepPath);
};

const getUploadStatus = (
Expand Down

0 comments on commit 1ebdf75

Please sign in to comment.