Skip to content

Commit

Permalink
Use the URL api rather than normalize-url
Browse files Browse the repository at this point in the history
The URL API is now in all browsers that we support: https://caniuse.com/url
  • Loading branch information
jcoyne committed Jan 25, 2023
1 parent 6150c0a commit 89c615b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 25 deletions.
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"jss-rtl": "^0.3.0",
"lodash": "^4.17.11",
"manifesto.js": "^4.2.0",
"normalize-url": "^4.5.0",
"openseadragon": "^2.4.2",
"prop-types": "^15.6.2",
"re-reselect": "^4.0.0",
Expand Down
8 changes: 2 additions & 6 deletions src/lib/CanvasWorld.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import normalizeUrl from 'normalize-url';
import MiradorCanvas from './MiradorCanvas';

/**
Expand Down Expand Up @@ -136,13 +135,10 @@ export default class CanvasWorld {
/** Get the IIIF content resource for an image */
contentResource(infoResponseId) {
const miradorCanvas = this.canvases.find(c => c.imageServiceIds.some(id => (
id && infoResponseId && normalizeUrl(id, { stripAuthentication: false })
=== normalizeUrl(infoResponseId, { stripAuthentication: false }))));
id && infoResponseId && (new URL(id).href === new URL(infoResponseId).href))));
if (!miradorCanvas) return undefined;
return miradorCanvas.imageResources
.find(r => (
normalizeUrl(r.getServices()[0].id, { stripAuthentication: false })
=== normalizeUrl(infoResponseId, { stripAuthentication: false })));
.find(r => (new URL(r.getServices()[0].id).href === new URL(infoResponseId).href));
}

/** @private */
Expand Down
4 changes: 1 addition & 3 deletions src/state/sagas/iiif.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
all, call, put, select, takeEvery,
} from 'redux-saga/effects';
import { Utils } from 'manifesto.js';
import normalizeUrl from 'normalize-url';
import ActionTypes from '../actions/action-types';
import {
receiveManifest, receiveManifestFailure, receiveInfoResponse,
Expand Down Expand Up @@ -79,8 +78,7 @@ function* fetchIiifResourceWithAuth(url, iiifResource, options, { degraded, fail

const id = json['@id'] || json.id;
if (response.ok) {
if (normalizeUrl(id, { stripAuthentication: false })
=== normalizeUrl(url.replace(/info\.json$/, ''), { stripAuthentication: false })) {
if (new URL(id).href === new URL(url.replace(/info\.json$/, '').href)) {
yield put(success({ json, response, tokenServiceId }));
return;
}
Expand Down

0 comments on commit 89c615b

Please sign in to comment.