summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/body1
-rw-r--r--.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/values29
-rw-r--r--.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/values2
-rw-r--r--.be/id-cache3
-rw-r--r--converter.js18
5 files changed, 47 insertions, 6 deletions
diff --git a/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/body b/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/body
new file mode 100644
index 0000000..44f7f4c
--- /dev/null
+++ b/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/body
@@ -0,0 +1 @@
+This is nonsense -- just get rid of [^0-9+] and be done with it.
diff --git a/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/values b/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/values
new file mode 100644
index 0000000..1bd466a
--- /dev/null
+++ b/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097/values
@@ -0,0 +1,29 @@
+{
+
+
+
+
+
+
+ "Author": "Mat\u011bj Cepl <mcepl@redhat.com>",
+
+
+
+
+
+
+ "Content-type": "text/plain",
+
+
+
+
+
+
+ "Date": "Fri, 09 Aug 2013 14:49:08 +0000"
+
+
+
+
+
+
+}
diff --git a/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/values b/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/values
index a3de10a..13b284b 100644
--- a/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/values
+++ b/.be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/values
@@ -26,7 +26,7 @@
- "status": "open",
+ "status": "fixed",
diff --git a/.be/id-cache b/.be/id-cache
index 2ab906b..6c840a5 100644
--- a/.be/id-cache
+++ b/.be/id-cache
@@ -1,4 +1,5 @@
80a8fa2a-3f0b-4188-860e-07531deadc7d .be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/80a8fa2a-3f0b-4188-860e-07531deadc7d
+ec76d352-9761-4e93-8b3c-11cebd0c4a84 .be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/ec76d352-9761-4e93-8b3c-11cebd0c4a84
+bae3dd1b-0909-4517-9aa7-e5e63584f097 .be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/bae3dd1b-0909-4517-9aa7-e5e63584f097
ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944 .be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944
b6156761-503a-458d-b7ad-535bc9358b79 .be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79
-ec76d352-9761-4e93-8b3c-11cebd0c4a84 .be/ecbc0d08-7f3d-4c4b-97ca-4be91fbb5944/bugs/b6156761-503a-458d-b7ad-535bc9358b79/comments/ec76d352-9761-4e93-8b3c-11cebd0c4a84
diff --git a/converter.js b/converter.js
index 1c8ae81..f90fe59 100644
--- a/converter.js
+++ b/converter.js
@@ -32,6 +32,8 @@ function translateObjectToContact(inRec) {
ValueError.prototype = new Error();
ValueError.prototype.constructor = ValueError;
+ const cleanPhoneNoRE = /[^0-9+]*/g;
+
/**
* Find the proper record (or create new one) in the multi-value
* attribute
@@ -117,6 +119,14 @@ function translateObjectToContact(inRec) {
}
}
+ /**
+ * Firefox OS doesn’t recognize well formatted phone numbers, and
+ * works best with the plain number-only ones.
+ */
+ function cleanPhoneNumber(inNo) {
+ return inNo.replace(cleanPhoneNoRE, "");
+ }
+
for (var key in inRec) {
if (["birthyear", "birthmonth", "birthday"].indexOf(key) !== -1) {
// We have alternatively either whole date in birthyear field,
@@ -159,14 +169,14 @@ function translateObjectToContact(inRec) {
}
else if (key === "facsimiletelephonenumber") {
curRec = findSubElement("tel", "fax");
- curRec.value = inRec[key];
+ curRec.value = cleanPhoneNumber(inRec[key]);
}
else if (key === "givenName") {
contact.givenName = [inRec[key]];
}
else if (key === "homePhone") {
curRec = findSubElement("tel", "home");
- curRec.value = inRec[key];
+ curRec.value = cleanPhoneNumber(inRec[key]);
}
else if (key === "l") {
curRec = findSubElement("adr", "work");
@@ -182,7 +192,7 @@ function translateObjectToContact(inRec) {
}
else if (key === "mobile") {
curRec = findSubElement("tel", "mobile");
- curRec.value = inRec[key];
+ curRec.value = cleanPhoneNumber(inRec[key]);
}
else if (key === "mozillaHomeCountryName") {
curRec = findSubElement("adr", "home");
@@ -275,7 +285,7 @@ function translateObjectToContact(inRec) {
}
else if (key === "telephoneNumber") {
curRec = findSubElement("tel", "work");
- curRec.value = inRec[key];
+ curRec.value = cleanPhoneNumber(inRec[key]);
}
else if (key === "title") {
contact.jobTitle = [inRec[key]];