Skip to content

Commit 64d22bf

Browse files
committed
const
1 parent f35b7dd commit 64d22bf

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

client/src/config/entrypoint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const entrypoint = new URL(
1+
export const ENTRYPOINT = new URL(
22
process.env.REACT_APP_API_ENTRYPOINT,
33
window.location.href
44
);

client/src/utils/dataAccess.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { entrypoint } from '../config/entrypoint';
1+
import { ENTRYPOINT } from '../config/entrypoint';
22
import { SubmissionError } from 'redux-form';
33
import has from 'lodash/has';
44
import mapValues from 'lodash/mapValues';
55

6-
const jsonLdMimeType = 'application/ld+json';
6+
const MIME_TYPE = 'application/ld+json';
77

88
export function fetch(id, options = {}) {
99
if ('undefined' === typeof options.headers) options.headers = new Headers();
1010
if (null === options.headers.get('Accept'))
11-
options.headers.set('Accept', jsonLdMimeType);
11+
options.headers.set('Accept', MIME_TYPE);
1212

1313
if (
1414
'undefined' !== options.body &&
1515
!(options.body instanceof FormData) &&
1616
null === options.headers.get('Content-Type')
1717
)
18-
options.headers.set('Content-Type', jsonLdMimeType);
18+
options.headers.set('Content-Type', MIME_TYPE);
1919

20-
return global.fetch(new URL(id, entrypoint), options).then(response => {
20+
return global.fetch(new URL(id, ENTRYPOINT), options).then(response => {
2121
if (response.ok) return response;
2222

2323
return response.json().then(json => {
@@ -41,7 +41,7 @@ export function mercureSubscribe(url) {
4141
export function normalize(data) {
4242
// Resolve IDs to absolute URLs
4343
if (has(data, '@id'))
44-
data['@id'] = new URL(data['@id'], entrypoint).toString();
44+
data['@id'] = new URL(data['@id'], ENTRYPOINT).toString();
4545

4646
if (has(data, 'hydra:member')) {
4747
// Normalize items in collections
@@ -54,9 +54,9 @@ export function normalize(data) {
5454
mapValues(data, value => {
5555
if (Array.isArray(value))
5656
return value.map(
57-
v => (has(v, '@id') ? new URL(v['@id'], entrypoint).toString() : v)
57+
v => (has(v, '@id') ? new URL(v['@id'], ENTRYPOINT).toString() : v)
5858
);
59-
if (has(value, '@id')) return new URL(value['@id'], entrypoint).toString();
59+
if (has(value, '@id')) return new URL(value['@id'], ENTRYPOINT).toString();
6060
return value;
6161
});
6262

@@ -72,5 +72,5 @@ export function extractHubURL(response) {
7272
);
7373
if (!matches || !matches[1]) return null;
7474

75-
return new URL(matches[1], entrypoint);
75+
return new URL(matches[1], ENTRYPOINT);
7676
}

0 commit comments

Comments
 (0)