summaryrefslogtreecommitdiff
path: root/src/gmutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmutil.c')
-rw-r--r--src/gmutil.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gmutil.c b/src/gmutil.c
index 0e0cccc5..32bf356f 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -272,6 +272,21 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat
272 return absolute; 272 return absolute;
273} 273}
274 274
275iBool isLikelyUrl_String(const iString *d) {
276 /* Guess whether a human intends the string to be an URL. This is supposed to be fuzzy;
277 not completely per-spec: a) begins with a scheme; b) has something that looks like a
278 hostname */
279 iRegExp *pattern = new_RegExp("^([a-z]+:)?//.*|"
280 "^(//)?([^/?#: ]+)([/?#:].*)$|"
281 "^(\\w+(\\.\\w+)+|localhost)$",
282 caseInsensitive_RegExpOption);
283 iRegExpMatch m;
284 init_RegExpMatch(&m);
285 const iBool likelyUrl = matchString_RegExp(pattern, d, &m);
286 iRelease(pattern);
287 return likelyUrl;
288}
289
275static iBool equalPuny_(const iString *d, iRangecc orig) { 290static iBool equalPuny_(const iString *d, iRangecc orig) {
276 if (!endsWith_String(d, "-")) { 291 if (!endsWith_String(d, "-")) {
277 return iFalse; /* This is a sufficient condition? */ 292 return iFalse; /* This is a sufficient condition? */