Skip to content

Commit

Permalink
fix(api): call encodeURIComponent on replicant namespace and name whe…
Browse files Browse the repository at this point in the history
…n autogenerating schemaPath
  • Loading branch information
astral-arsonist committed Dec 17, 2016
1 parent 4572c34 commit 973d4ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/api.js
Expand Up @@ -328,7 +328,8 @@ NodeCG.Replicant = function (name, namespace, opts) {
* @param {boolean} [opts.persistent=true] - Whether to persist the Replicant's value to disk on every change.
* Persisted values are re-loaded on startup.
* @param {string} [opts.schemaPath] - The filepath at which to look for a JSON Schema for this Replicant.
* Defaults to `nodecg/bundles/${bundleName}/schemas/${replicantName}.json`.
* Defaults to `nodecg/bundles/${bundleName}/schemas/${replicantName}.json`. Please note that this default
* path will be URIEncoded to ensure that it results in a valid filename.
*
* @example
* const myRep = nodecg.Replicant('myRep', {defaultValue: 123});
Expand All @@ -353,7 +354,7 @@ NodeCG.prototype.Replicant = function (name, namespace, opts) {
}

if (typeof opts.schemaPath === 'undefined') {
opts.schemaPath = `bundles/${namespace}/schemas/${name}.json`;
opts.schemaPath = `bundles/${encodeURIComponent(namespace)}/schemas/${encodeURIComponent(name)}.json`;
}

return new NodeCG.Replicant(name, namespace, opts);
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/dist/browserifiedApi.map.json

Large diffs are not rendered by default.

0 comments on commit 973d4ed

Please sign in to comment.