Skip to content

Commit

Permalink
fix: ignore attrs that might interfere with query generation
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 18, 2018
1 parent d3041e7 commit 3a37269
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/codegen/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
const qs = require('querystring')

// these are built-in query parameters so should be ignored
// if the user happen to add them as attrs
const ignoreList = [
'id',
'index',
'src',
'type'
]

// transform the attrs on a SFC block descriptor into a resourceQuery string
exports.attrsToQuery = (attrs, langFallback) => {
let query = ``
for (const name in attrs) {
const value = attrs[name]
if (name !== 'src') {
if (!ignoreList.includes(name)) {
query += `&${qs.escape(name)}=${value ? qs.escape(value) : ``}`
}
}
Expand Down

0 comments on commit 3a37269

Please sign in to comment.