summaryrefslogtreecommitdiff
path: root/src/gmutil.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-17 17:01:01 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-17 17:01:01 +0200
commitcdb955bfe2be425ed483273d4341f8fd6c8165ca (patch)
tree019ba02b640f59f68cb6413bcfb3667351ddd203 /src/gmutil.c
parentc6a3afccfc5ef679a82275c5f045336c2d48f643 (diff)
parentdd90cda682180f6472aa030d01317f70cc3d7282 (diff)
Merge branch 'dev' of skyjake.fi:skyjake/lagrange into dev
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? */