Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Diff: services/URIBeaconConfigService.h
- Revision:
- 317:50643fab3ecf
- Parent:
- 316:98e58b0c4441
- Child:
- 318:fe467afccd02
--- a/services/URIBeaconConfigService.h Fri Mar 13 09:57:57 2015 +0000
+++ b/services/URIBeaconConfigService.h Fri Mar 13 09:57:57 2015 +0000
@@ -376,16 +376,6 @@
* Encode a human-readable URI into the binary format defined by URIBeacon spec (https://github.com/google/uribeacon/tree/master/specification).
*/
static void encodeURI(const char *uriDataIn, UriData_t uriDataOut, size_t &sizeofURIDataOut) {
- sizeofURIDataOut = 0;
- memset(uriDataOut, 0, sizeof(UriData_t));
-
- if ((uriDataIn == NULL) || (strlen(uriDataIn) == 0)) {
- return;
- }
-
- /*
- * handle prefix
- */
const char *prefixes[] = {
"http://www.",
"https://www.",
@@ -394,18 +384,6 @@
"urn:uuid:"
};
const size_t NUM_PREFIXES = sizeof(prefixes) / sizeof(char *);
- for (unsigned i = 0; i < NUM_PREFIXES; i++) {
- size_t prefixLen = strlen(prefixes[i]);
- if (strncmp(uriDataIn, prefixes[i], prefixLen) == 0) {
- uriDataOut[sizeofURIDataOut++] = i;
- uriDataIn += prefixLen;
- break;
- }
- }
-
- /*
- * handle suffixes
- */
const char *suffixes[] = {
".com/",
".org/",
@@ -423,6 +401,29 @@
".gov"
};
const size_t NUM_SUFFIXES = sizeof(suffixes) / sizeof(char *);
+
+ sizeofURIDataOut = 0;
+ memset(uriDataOut, 0, sizeof(UriData_t));
+
+ if ((uriDataIn == NULL) || (strlen(uriDataIn) == 0)) {
+ return;
+ }
+
+ /*
+ * handle prefix
+ */
+ for (unsigned i = 0; i < NUM_PREFIXES; i++) {
+ size_t prefixLen = strlen(prefixes[i]);
+ if (strncmp(uriDataIn, prefixes[i], prefixLen) == 0) {
+ uriDataOut[sizeofURIDataOut++] = i;
+ uriDataIn += prefixLen;
+ break;
+ }
+ }
+
+ /*
+ * handle suffixes
+ */
while (*uriDataIn && (sizeofURIDataOut < URI_DATA_MAX)) {
/* check for suffix match */
unsigned i;
