From 25a14de397f0fd6bdc3b6981cfc0ccb5625082a7 Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Tue, 31 Mar 2026 14:24:35 -0700 Subject: [PATCH 1/2] append DOI and ARXIV URL origin when adding new url in the missing record form --- .../FeedbackForms/MissingRecord/UrlsField.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/FeedbackForms/MissingRecord/UrlsField.tsx b/src/components/FeedbackForms/MissingRecord/UrlsField.tsx index 5d71b3eba..21d0efd25 100644 --- a/src/components/FeedbackForms/MissingRecord/UrlsField.tsx +++ b/src/components/FeedbackForms/MissingRecord/UrlsField.tsx @@ -24,6 +24,10 @@ const typeOptions: SelectOption[] = resourceUrlTypes.map((t) => value: t as string, })); +const DOI_ORIGIN = 'https://doi.org'; + +const ARXIV_ORIGIN = 'https://arxiv.org'; + export const UrlsTable = ({ editable }: { editable: boolean }) => { const isClient = useIsClient(); @@ -37,7 +41,7 @@ export const UrlsTable = ({ editable }: { editable: boolean }) => { }); // New row being added - const [newUrl, setNewUrl] = useState({ type: 'arXiv', url: '' }); + const [newUrl, setNewUrl] = useState({ type: 'arXiv', url: `${ARXIV_ORIGIN}/` }); // Existing row being edited const [editUrl, setEditUrl] = useState<{ index: number; url: IResourceUrl }>({ @@ -67,7 +71,9 @@ export const UrlsTable = ({ editable }: { editable: boolean }) => { try { const testUrl = new URL(url); - return VALID_PROTOCOLS.includes(testUrl.protocol); + return testUrl.origin === DOI_ORIGIN || testUrl.origin === ARXIV_ORIGIN + ? testUrl.pathname.length > 1 + : VALID_PROTOCOLS.includes(testUrl.protocol); } catch { return false; } @@ -80,7 +86,8 @@ export const UrlsTable = ({ editable }: { editable: boolean }) => { // Changes to fields for adding new url const handleNewTypeChange = (option: SelectOption) => { - setNewUrl((prev) => ({ ...prev, type: option.id })); + const origin = option.id === 'DOI' ? DOI_ORIGIN : option.id === 'arXiv' ? ARXIV_ORIGIN : ''; + setNewUrl({ url: `${origin}/`, type: option.id }); }; const handleNewUrlChange = (e: ChangeEvent) => { @@ -90,7 +97,7 @@ export const UrlsTable = ({ editable }: { editable: boolean }) => { const handleAddUrl = () => { append(newUrl); // clear input fields - setNewUrl({ type: 'arXiv', url: '' }); + setNewUrl({ type: 'arXiv', url: `${ARXIV_ORIGIN}/` }); (newURLTypeInputRef.current as SelectInstance).focus(); }; From f48ac987661cb09a749865aad64d2c0940c66e59 Mon Sep 17 00:00:00 2001 From: Jennifer Chen Date: Mon, 6 Apr 2026 11:48:56 -0700 Subject: [PATCH 2/2] move DOI and ARXIV origins to config --- src/components/FeedbackForms/MissingRecord/UrlsField.tsx | 9 ++++----- src/config.ts | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/FeedbackForms/MissingRecord/UrlsField.tsx b/src/components/FeedbackForms/MissingRecord/UrlsField.tsx index 21d0efd25..e7d473286 100644 --- a/src/components/FeedbackForms/MissingRecord/UrlsField.tsx +++ b/src/components/FeedbackForms/MissingRecord/UrlsField.tsx @@ -8,6 +8,7 @@ import { SelectInstance } from 'react-select'; import { FormValues } from './types'; import { IResourceUrl, ResourceUrlType, resourceUrlTypes } from '@/lib/useGetResourceLinks'; import { useIsClient } from '@/lib/useIsClient'; +import { EXTERNAL_URLS } from '@/config'; export const UrlsField = () => { return ( @@ -24,9 +25,7 @@ const typeOptions: SelectOption[] = resourceUrlTypes.map((t) => value: t as string, })); -const DOI_ORIGIN = 'https://doi.org'; - -const ARXIV_ORIGIN = 'https://arxiv.org'; +const { DOI_ORIGIN, ARXIV_ORIGIN } = EXTERNAL_URLS; export const UrlsTable = ({ editable }: { editable: boolean }) => { const isClient = useIsClient(); @@ -86,8 +85,8 @@ export const UrlsTable = ({ editable }: { editable: boolean }) => { // Changes to fields for adding new url const handleNewTypeChange = (option: SelectOption) => { - const origin = option.id === 'DOI' ? DOI_ORIGIN : option.id === 'arXiv' ? ARXIV_ORIGIN : ''; - setNewUrl({ url: `${origin}/`, type: option.id }); + const origin = option.id === 'DOI' ? `${DOI_ORIGIN}/` : option.id === 'arXiv' ? `${ARXIV_ORIGIN}/` : ''; + setNewUrl({ url: origin, type: option.id }); }; const handleNewUrlChange = (e: ChangeEvent) => { diff --git a/src/config.ts b/src/config.ts index f645637ec..1ce49c397 100644 --- a/src/config.ts +++ b/src/config.ts @@ -79,6 +79,8 @@ export const EXTERNAL_URLS = { CFA_SAO_HOME_PAGE: 'https://www.cfa.harvard.edu/sao' as const, UAT: 'http://astrothesaurus.org', ORCID: 'https://orcid.org', + DOI_ORIGIN: 'https://doi.org', + ARXIV_ORIGIN: 'https://arxiv.org', }; export const TRACING_HEADERS = ['X-Original-Uri', 'X-Original-Forwarded-For', 'X-Forwarded-For', 'X-Amzn-Trace-Id'];