]> git.lizzy.rs Git - rust.git/commitdiff
Add has_url()
authortopecongiro <seuchida@gmail.com>
Tue, 31 Oct 2017 06:07:19 +0000 (15:07 +0900)
committertopecongiro <seuchida@gmail.com>
Tue, 31 Oct 2017 06:07:19 +0000 (15:07 +0900)
src/comment.rs

index 5112c333dee25ac9f36e460de47e6979a7241a59..156ae26725fafc57472182559da55fb34ac2b47f 100644 (file)
@@ -349,6 +349,12 @@ fn rewrite_comment_inner(
     Some(result)
 }
 
+/// Returns true if the given string MAY include URLs or alike.
+fn has_url(s: &str) -> bool {
+    // This function may return false positive, but should get its job done in most cases.
+    s.contains("https://") || s.contains("http://")
+}
+
 /// Given the span, rewrite the missing comment inside it if available.
 /// Note that the given span must only include comments (or leading/trailing whitespaces).
 pub fn rewrite_missing_comment(