Skip to content

Commit f9a85fe

Browse files
committed
Don't url-encode type/id when calling deleteRecord mutation.
1 parent 62fd2ea commit f9a85fe

File tree

8 files changed

+2540
-3208
lines changed

8 files changed

+2540
-3208
lines changed

.eslintrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module.exports = {
77
node: true,
88
},
99
parserOptions: {
10-
parser: 'babel-eslint',
10+
parser: '@babel/eslint-parser',
11+
requireConfigFile: false,
1112
ecmaVersion: 2018,
1213
sourceType: 'module',
1314
},

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Steps represent a sequence of tasks that will be executed as part of the job
2323
steps:
2424
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v3
2626

2727
- name: Test Suite
2828
run: |

examples/testapp/.eslintrc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module.exports = {
1111
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
1212
},
1313
parserOptions: {
14-
parser: 'babel-eslint',
14+
parser: '@babel/eslint-parser',
15+
requireConfigFile: false,
16+
ecmaVersion: 2018,
1517
},
1618
}

package.json

+35-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsonapi-vuex",
3-
"version": "5.10.0",
3+
"version": "5.11.0",
44
"description": "Access restructured JSONAPI data from a Vuex Store.",
55
"author": "Matthew Richardson <[email protected]>",
66
"scripts": {
@@ -17,59 +17,60 @@
1717
"src/"
1818
],
1919
"dependencies": {
20-
"jsonpath-plus": "^6.0.1",
20+
"jsonpath-plus": "^7.2.0",
2121
"lodash.get": "^4.4.2",
2222
"lodash.isequal": "^4.5.0",
2323
"lodash.merge": "^4.6.2",
2424
"lodash.set": "^4.3.2"
2525
},
2626
"devDependencies": {
27-
"@babel/core": "^7.15.0",
28-
"@babel/preset-env": "^7.15.0",
27+
"@babel/core": "^7.21.0",
28+
"@babel/eslint-parser": "^7.19.1",
29+
"@babel/preset-env": "^7.20.2",
2930
"@vue/cli-plugin-babel": "~5.0.8",
3031
"@vue/cli-plugin-e2e-nightwatch": "~5.0.8",
3132
"@vue/cli-plugin-eslint": "~5.0.8",
3233
"@vue/cli-plugin-vuex": "~5.0.8",
3334
"@vue/cli-service": "~5.0.8",
34-
"@vue/test-utils": "^1.2.2",
35-
"axios": "^0.21.1",
36-
"axios-mock-adapter": "^1.19.0",
37-
"babel-eslint": "^10.1.0",
38-
"babel-loader": "^8.2.2",
39-
"babel-plugin-istanbul": "^6.0.0",
35+
"@vue/test-utils": "^2.3.1",
36+
"axios": "^1.3.4",
37+
"axios-mock-adapter": "^1.21.2",
38+
"babel-loader": "^9.1.2",
39+
"babel-plugin-istanbul": "^6.1.1",
4040
"babel-polyfill": "^6.26.0",
41-
"chai": "^4.3.4",
41+
"chai": "^4.3.7",
4242
"chai-as-promised": "^7.1.1",
43-
"chromedriver": "^106",
44-
"concurrently": "^6.2.1",
45-
"core-js": "^3.16.1",
46-
"eslint": "^7.32.0",
47-
"eslint-config-prettier": "^8.3.0",
48-
"eslint-loader": "^4.0.2",
49-
"eslint-plugin-prettier": "^3.4.0",
50-
"eslint-plugin-prettier-vue": "^3.1.0",
51-
"eslint-plugin-vue": "^7.16.0",
43+
"chromedriver": "^110.0.0",
44+
"concurrently": "^7.6.0",
45+
"core-js": "^3.29.1",
46+
"eslint": "^8.36.0",
47+
"eslint-config-prettier": "^8.7.0",
48+
"eslint-plugin-prettier": "^4.2.1",
49+
"eslint-plugin-prettier-vue": "^4.2.0",
50+
"eslint-plugin-vue": "^9.9.0",
51+
"eslint-webpack-plugin": "^4.0.0",
5252
"fake-json-api-server": "^1.6.0",
53-
"geckodriver": "^3.0.1",
54-
"husky": "^7.0.1",
55-
"jsdoc": "^3.6.6",
56-
"karma": "^6.3.4",
53+
"geckodriver": "^3.2.0",
54+
"husky": "^8.0.3",
55+
"jsdoc": "^4.0.2",
56+
"karma": "^6.4.1",
5757
"karma-chai": "^0.1.0",
58-
"karma-coverage": "^2.0.3",
59-
"karma-firefox-launcher": "^2.1.1",
58+
"karma-coverage": "^2.2.0",
59+
"karma-firefox-launcher": "^2.1.2",
6060
"karma-mocha": "^2.0.1",
6161
"karma-sinon": "^1.0.5",
62-
"karma-verbose-reporter": "^0.0.6",
62+
"karma-verbose-reporter": "^0.0.8",
6363
"karma-webpack": "^5.0.0",
64-
"lint-staged": "^11.1.2",
65-
"mocha": "^9.0.3",
64+
"lint-staged": "^13.2.0",
65+
"mocha": "^10.2.0",
6666
"mocha-eslint": "^7.0.0",
67-
"nightwatch": "^2.3.0",
68-
"prettier": "^2.3.2",
69-
"sinon": "^14.0.0",
67+
"nightwatch": "^2.6.17",
68+
"prettier": "^2.8.4",
69+
"sinon": "^15.0.2",
7070
"sinon-chai": "^3.7.0",
71-
"vue": "^3.2.37",
72-
"vuex": "^4.0.0"
71+
"vue": "^3.2.47",
72+
"vuex": "^4.1.0",
73+
"webpack": "^5.0.0"
7374
},
7475
"peerDependencies": {
7576
"vue": "^3.0.11",

src/mutations.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default () => {
1717
* @param {(string|object)} record - The record to be deleted
1818
*/
1919
deleteRecord: (state, record) => {
20-
const [type, id] = utils.getTypeId(record)
20+
const [type, id] = utils.getTypeId(record, false)
2121
if (!type || !id) {
2222
throw `deleteRecord: Missing type or id: ${record}`
2323
}

tests/unit/jsonapi-vuex.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ describe('jsonapi-vuex tests', function () {
147147
deleteRecord(storeWidget1, 'widget/1')
148148
expect(storeWidget1[normWidget1['_jv']['type']]).to.not.have.key(normWidget1['_jv']['id'])
149149
})
150+
it('should delete a record (string) from the store without url-encoding it', function () {
151+
const { deleteRecord } = jm.mutations
152+
let storeCompound1 = {
153+
widget: {
154+
'hello:world': { _jv: { type: 'widget', id: 'hello:world' } },
155+
},
156+
}
157+
deleteRecord(storeCompound1, 'widget/hello:world')
158+
expect(storeCompound1['widget']).to.not.have.key('hello:world')
159+
})
150160
it('should throw an error if no type or id present.', function () {
151161
const { deleteRecord } = jm.mutations
152162
// expect needs a function to call, not the return from a function

webpack.config.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
const ESLintPlugin = require('eslint-webpack-plugin');
2+
3+
const options = {
4+
extensions: [`js`, `jsx`],
5+
exclude: [
6+
'node_modules',
7+
],
8+
failOnWarning: false,
9+
failOnError: true,
10+
}
111
module.exports = {
212
mode: 'production',
313
performance: { hints: false },
14+
plugins: [new ESLintPlugin(options)],
415
// Re-enable Errors (disabled in production mode) to allow eslint to stop build
516
optimization: {
6-
noEmitOnErrors: true,
17+
emitOnErrors: false,
718
},
819
module: {
920
rules: [
10-
{
11-
enforce: 'pre',
12-
test: /\.js$/,
13-
exclude: /(node_modules|bower_components)/,
14-
loader: 'eslint-loader',
15-
options: {
16-
failOnWarning: false,
17-
failOnError: true,
18-
},
19-
},
2021
{
2122
test: /\.js$/,
2223
exclude: /(node_modules|bower_components)/,

0 commit comments

Comments
 (0)