Skip to content

Commit

Permalink
support for webpack 5
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuaz committed Jun 4, 2022
1 parent 375d318 commit fb17841
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"test:clean": "find test/**/build/ -name '*.jpg' -o -name '*.png' -o -name '*.avif' -o -name '*.wep' -o -name '*.js' | xargs rm -f",
"test": "npm run build && npm run test:clean && webpack --config=./test/jimp/webpack.config.js && webpack --config=./test/sharp/webpack.config.js && jest"
},
"np": {
"yarn": false,
"contents": "lib"
},
"files": [
"lib",
"jimp.js",
Expand Down
2 changes: 0 additions & 2 deletions src/interpolateName.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

import { util } from 'webpack'
import * as path from 'path'

Expand Down
20 changes: 9 additions & 11 deletions src/parseQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

import * as JSON5 from 'json5'

interface LooseObject {
Expand All @@ -13,17 +11,17 @@ const specialValues: LooseObject = {
}

function parseQuery(query: string): LooseObject {
if (query.substr(0, 1) !== '?') {
if (query.substring(0, 1) !== '?') {
throw new Error("A valid query string passed to parseQuery should begin with '?'")
}

query = query.substr(1)
query = query.substring(1)

if (!query) {
return {}
}

if (query.substr(0, 1) === '{' && query.substr(-1) === '}') {
if (query.substring(0, 1) === '{' && query.substring(-1) === '}') {
return JSON5.parse(query)
}

Expand All @@ -42,8 +40,8 @@ function parseQuery(query: string): LooseObject {
if (specialValues.hasOwnProperty(value)) {
value = specialValues[value]
}
if (name.substr(-2) === '[]') {
name = decodeURIComponent(name.substr(0, name.length - 2))
if (name.substring(-2) === '[]') {
name = decodeURIComponent(name.substring(0, name.length - 2))

if (!Array.isArray(result[name])) {
result[name] = []
Expand All @@ -55,10 +53,10 @@ function parseQuery(query: string): LooseObject {
result[name] = value
}
} else {
if (arg.substr(0, 1) === '-') {
result[decodeURIComponent(arg.substr(1))] = false
} else if (arg.substr(0, 1) === '+') {
result[decodeURIComponent(arg.substr(1))] = true
if (arg.substring(0, 1) === '-') {
result[decodeURIComponent(arg.substring(1))] = false
} else if (arg.substring(0, 1) === '+') {
result[decodeURIComponent(arg.substring(1))] = true
} else {
result[decodeURIComponent(arg)] = true
}
Expand Down

0 comments on commit fb17841

Please sign in to comment.