This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
URLFinder.java
66 lines (58 loc) · 1.47 KB
/
URLFinder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package cmd.functionality_commands.output_parsing;
/**
* Collector for Google CLI deployment urls
*/
public class URLFinder {
// string containing url
private String result;
// ignore SSL/TLS certificate validation in OpenWhisk
private final boolean openWhiskIgnoreSSL;
/**
* Default constructor
*/
public URLFinder() {
result = "";
openWhiskIgnoreSSL = false;
}
/**
* One argument constructor
* @param openWhiskIgnoreSSL tells whether to ignore SSL/TLS certificate validation or not in OpenWhisk
*/
public URLFinder(boolean openWhiskIgnoreSSL) {
result = "";
this.openWhiskIgnoreSSL = openWhiskIgnoreSSL;
}
/**
* Searches for the URL inside the passed string
* @param string output line to perform search on
*/
public void findGoogleCloudFunctionsUrl(String string) {
if (string.contains("url: ")) {
// exclude un-needed information and blank spaces
String url = string.substring(string.indexOf("url: "));
// remove preamble
result = url.replace("url: ", "");
}
}
/**
* Searches for the URL inside the passed string
* @param string output line to perform search on
*/
public void findOpenWhiskUrl(String string) {
if (string.contains("https")) {
// url found
if (openWhiskIgnoreSSL) {
// ignore ssl certificate validation
string = string.replace("https", "http");
}
result = string;
}
}
/**
* Get final result
* @return string containing the url
*/
public String getResult() {
return result;
}
}