Skip to content

Commit b607f9b

Browse files
committed
Use the URL api rather than normalize-url
The URL API is now in all browsers that we support: https://caniuse.com/url
1 parent dddc0e7 commit b607f9b

File tree

4 files changed

+3
-25
lines changed

4 files changed

+3
-25
lines changed

package-lock.json

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"jss-rtl": "^0.3.0",
4949
"lodash": "^4.17.11",
5050
"manifesto.js": "^4.2.0",
51-
"normalize-url": "^4.5.0",
5251
"openseadragon": "^2.4.2",
5352
"prop-types": "^15.6.2",
5453
"re-reselect": "^4.0.0",

src/lib/CanvasWorld.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import normalizeUrl from 'normalize-url';
21
import MiradorCanvas from './MiradorCanvas';
32

43
/**
@@ -136,13 +135,10 @@ export default class CanvasWorld {
136135
/** Get the IIIF content resource for an image */
137136
contentResource(infoResponseId) {
138137
const miradorCanvas = this.canvases.find(c => c.imageServiceIds.some(id => (
139-
id && infoResponseId && normalizeUrl(id, { stripAuthentication: false })
140-
=== normalizeUrl(infoResponseId, { stripAuthentication: false }))));
138+
id && infoResponseId && (new URL(id).href === new URL(infoResponseId).href))));
141139
if (!miradorCanvas) return undefined;
142140
return miradorCanvas.imageResources
143-
.find(r => (
144-
normalizeUrl(r.getServices()[0].id, { stripAuthentication: false })
145-
=== normalizeUrl(infoResponseId, { stripAuthentication: false })));
141+
.find(r => (new URL(r.getServices()[0].id).href === new URL(infoResponseId).href));
146142
}
147143

148144
/** @private */

src/state/sagas/iiif.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
} from 'redux-saga/effects';
44
import fetch from 'isomorphic-unfetch';
55
import { Utils } from 'manifesto.js';
6-
import normalizeUrl from 'normalize-url';
76
import ActionTypes from '../actions/action-types';
87
import {
98
receiveManifest, receiveManifestFailure, receiveInfoResponse,
@@ -80,8 +79,7 @@ function* fetchIiifResourceWithAuth(url, iiifResource, options, { degraded, fail
8079

8180
const id = json['@id'] || json.id;
8281
if (response.ok) {
83-
if (normalizeUrl(id, { stripAuthentication: false })
84-
=== normalizeUrl(url.replace(/info\.json$/, ''), { stripAuthentication: false })) {
82+
if (new URL(id).href === new URL(url.replace(/info\.json$/, '').href)) {
8583
yield put(success({ json, response, tokenServiceId }));
8684
return;
8785
}

0 commit comments

Comments
 (0)