Skip to content

Commit

Permalink
drop jshash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Apr 5, 2022
1 parent 89f1076 commit 4d52f48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 1 addition & 3 deletions plugins/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
"singleQuote": true,
"printWidth": 100
},
"dependencies": {
"jshashes": "^1.0.8"
},
"dependencies": {},
"peerDependencies": {
"wtf_wikipedia": ">=9.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions plugins/image/scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import wtf from '../../src/index.js'
import plg from './src/index.js'
wtf.extend(plg)

wtf.fetch('Hamburg').then(async (doc) => {
console.log(await doc.mainImage().license())
wtf.fetch('Radiohead').then(async (doc) => {
console.log(await doc.mainImage().commonsURL())
// https://wikipedia.org/wiki/Special:Redirect/file/Flag_of_Hamburg.svg?width=300
})
7 changes: 5 additions & 2 deletions plugins/image/src/url-hash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import jsHash from 'jshashes'
// import jsHash from 'jshashes'
import md5 from './_md5.js'


const server = 'https://upload.wikimedia.org/wikipedia/commons/'

Expand All @@ -17,7 +19,8 @@ const encodeTitle = function (file) {
const commonsURL = function () {
let file = this.data.file
let title = encodeTitle(file)
let hash = new jsHash.MD5().hex(title)
// let hash = new jsHash.MD5().hex(title)
let hash = md5(title)
let path = hash.substr(0, 1) + '/' + hash.substr(0, 2) + '/'
title = encodeURIComponent(title)
path += title
Expand Down

0 comments on commit 4d52f48

Please sign in to comment.