Skip to content

Commit

Permalink
Spin off src/util/response-to-data-uri.
Browse files Browse the repository at this point in the history
  • Loading branch information
Treora committed Jul 13, 2017
1 parent 70fd0f0 commit a5ba6f1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"redux-observable": "^0.14.1",
"redux-query-sync": "^0.1.4",
"redux-thunk": "^2.2.0",
"response-to-data-url": "^0.1.0",
"rxjs": "^5.4.1",
"semantic-ui-css": "git+https://github.com/Treora/semantic-ui-css.git#1d2237f",
"semantic-ui-react": "^0.70.0",
Expand Down
4 changes: 2 additions & 2 deletions src/freeze-dry/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import responseToDataUri from 'src/util/response-to-data-uri'
import responseToDataUrl from 'response-to-data-url'
import whenAllSettled from 'when-all-settled'


Expand All @@ -9,7 +9,7 @@ export function removeNode(node) {
export async function urlToDataUri(url) {
try {
const response = await fetch(url, {cache: 'force-cache'})
const dataUri = await responseToDataUri(response)
const dataUri = await responseToDataUrl(response)
return dataUri
} catch (err) {
return 'about:invalid'
Expand Down
6 changes: 3 additions & 3 deletions src/freeze-dry/common.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env jest */

import { inlineUrlsInAttributes, urlToDataUri, removeNode } from 'src/freeze-dry/common'
import * as responseToDataUri from 'src/util/response-to-data-uri'
import * as responseToDataUrl from 'response-to-data-url'
import { dataURLToBlob } from 'blob-util'


Expand All @@ -26,7 +26,7 @@ describe('removeNode', () => {
describe('urlToDataUri', () => {
test('should return a dataUri given a URL', async () => {
const someDataUri = 'data:text/html,<h1>bananas</h1>'
const spy = jest.spyOn(responseToDataUri, 'default').mockImplementation(async () => {
const spy = jest.spyOn(responseToDataUrl, 'default').mockImplementation(async () => {
return someDataUri
})
const dataUri = await urlToDataUri('https://example.com/page')
Expand All @@ -35,7 +35,7 @@ describe('urlToDataUri', () => {
})

test('should return a "about:invalid" upon failure', async () => {
const spy = jest.spyOn(responseToDataUri, 'default').mockImplementation(async () => {
const spy = jest.spyOn(responseToDataUrl, 'default').mockImplementation(async () => {
throw new Error('mock error')
})
const dataUri = await urlToDataUri('http://example.com')
Expand Down
4 changes: 2 additions & 2 deletions src/page-analysis/background/get-fav-icon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import responseToDataURI from 'src/util/response-to-data-uri'
import responseToDataUrl from 'response-to-data-url'

// Get a tab's fav-icon (website logo) as a data URI
async function getFavIcon({tabId}) {
Expand All @@ -9,7 +9,7 @@ async function getFavIcon({tabId}) {
}

const response = await fetch(tab.favIconUrl)
const dataURI = await responseToDataURI(response)
const dataURI = await responseToDataUrl(response)
return dataURI
}

Expand Down
11 changes: 0 additions & 11 deletions src/util/response-to-data-uri.js

This file was deleted.

6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7131,6 +7131,12 @@ resolve@^1.1.3, resolve@^1.1.4, resolve@^1.1.6, resolve@^1.1.7, resolve@^1.3.2,
dependencies:
path-parse "^1.0.5"

response-to-data-url@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/response-to-data-url/-/response-to-data-url-0.1.0.tgz#da1eb5724d114bd6568dda890acfbc3f905663ab"
dependencies:
postinstall-build "^3.0.1"

restore-cursor@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541"
Expand Down

0 comments on commit a5ba6f1

Please sign in to comment.