In createNameArray, rename argument name to uri.
diff --git a/js/Name.js b/js/Name.js
index c4bb39f..605f110 100644
--- a/js/Name.js
+++ b/js/Name.js
@@ -37,38 +37,38 @@
return this.to_uri();
};
-/* Parse name as a URI and return an array of Uint8Array components.
+/* Parse uri as a URI and return an array of Uint8Array components.
*
*/
-Name.createNameArray = function(name) {
- name = name.trim();
- if (name.length <= 0)
+Name.createNameArray = function(uri) {
+ uri = uri.trim();
+ if (uri.length <= 0)
return [];
- var iColon = name.indexOf(':');
+ var iColon = uri.indexOf(':');
if (iColon >= 0) {
// Make sure the colon came before a '/'.
- var iFirstSlash = name.indexOf('/');
+ var iFirstSlash = uri.indexOf('/');
if (iFirstSlash < 0 || iColon < iFirstSlash)
// Omit the leading protocol such as ndn:
- name = name.substr(iColon + 1, name.length - iColon - 1).trim();
+ uri = uri.substr(iColon + 1, uri.length - iColon - 1).trim();
}
- if (name[0] == '/') {
- if (name.length >= 2 && name[1] == '/') {
+ if (uri[0] == '/') {
+ if (uri.length >= 2 && uri[1] == '/') {
// Strip the authority following "//".
- var iAfterAuthority = name.indexOf('/', 2);
+ var iAfterAuthority = uri.indexOf('/', 2);
if (iAfterAuthority < 0)
// Unusual case: there was only an authority.
return [];
else
- name = name.substr(iAfterAuthority + 1, name.length - iAfterAuthority - 1).trim();
+ uri = uri.substr(iAfterAuthority + 1, uri.length - iAfterAuthority - 1).trim();
}
else
- name = name.substr(1, name.length - 1).trim();
+ uri = uri.substr(1, uri.length - 1).trim();
}
- var array = name.split('/');
+ var array = uri.split('/');
// Unescape the components.
for (var i = 0; i < array.length; ++i) {
@@ -344,14 +344,14 @@
}
else {
for (var i = 0; i < component.length; ++i) {
- var value = component[i];
+ var x = component[i];
// Check for 0-9, A-Z, a-z, (+), (-), (.), (_)
- if (value >= 0x30 && value <= 0x39 || value >= 0x41 && value <= 0x5a ||
- value >= 0x61 && value <= 0x7a || value == 0x2b || value == 0x2d ||
- value == 0x2e || value == 0x5f)
- result += String.fromCharCode(value);
+ if (x >= 0x30 && x <= 0x39 || x >= 0x41 && x <= 0x5a ||
+ x >= 0x61 && x <= 0x7a || x == 0x2b || x == 0x2d ||
+ x == 0x2e || x == 0x5f)
+ result += String.fromCharCode(x);
else
- result += "%" + (value < 16 ? "0" : "") + value.toString(16).toUpperCase();
+ result += "%" + (x < 16 ? "0" : "") + x.toString(16).toUpperCase();
}
}
return result;