department-of-veterans-affairs/vets-website

View on GitHub
src/applications/form-renderer/utils/url.js

Summary

Maintainability
A
0 mins
Test Coverage
import { removeLeadingSlash, removeTrailingSlash } from './string';

export const getFormIdFromUrl = (url, rootUrl) => {
  const noSlashRootUrl = removeLeadingSlash(removeTrailingSlash(rootUrl));
  return url.match(new RegExp(`${noSlashRootUrl}/([a-zA-Z0-9-_]+)/?`))?.[1];
};