package com.leocardz.link.preview.library;

import java.net.URL;
import java.util.ArrayList;

public class SearchUrls {

	public static final int ALL = 0;
	public static final int FIRST = 1;

	/** It finds urls inside the text and return the matched ones */
	public static ArrayList<String> matches(String text) {
		return matches(text, ALL);
	}

	/** It finds urls inside the text and return the matched ones */
	public static ArrayList<String> matches(String text, int results) {

		ArrayList<String> urls = new ArrayList<String>();

		String[] splitString = (text.split(" "));
		for (String string : splitString) {

			try {
				URL item = new URL(string);
				urls.add(item.toString());
			} catch (Exception e) {
			}

			if (results == FIRST && urls.size() > 0)
				break;
		}

		return urls;
	}

}

@@ -611,16 +611,85 @@
 ring) %7B%0A
+%09%09%09if(!string.contains(%22://%22))%7B%0A%09%09%09%09string = %22http://%22 + string;%0A%09%09%09%7D
 %0A%09%09%09try 

Handle no protocol URLs. If not protocol provided, try using http:// as a default