MCPcopy Create free account
hub / github.com/EsperoTech/yaade / setRaw

Method setRaw

server/src/main/java/com/postman/collection/Url.java:73–119  ·  view source on GitHub ↗

Sets the raw URL. The host, path, query,protocl, query and port properties are parsed from the raw url. Parsing does not always result in these properties being filled, as collection URLs are not always valid URLs in the java sense. For example, URLs containing variables may not produce discrete va

(String rawUrl)

Source from the content-addressed store, hash-verified

71 * @param rawUrl The raw URL as a String. The URL is not validated
72 */
73 public void setRaw(String rawUrl) {
74
75 //Is there a query String
76
77 String queryString;
78
79 this.raw = rawUrl;
80
81
82 if (rawUrl.split("\\?").length == 2) {
83 queryString = rawUrl.split("\\?")[1];
84 rawUrl = rawUrl.split("\\?")[0];
85 this.setQuery(queryString);
86 }
87
88 String regex = "^(https?)(://)(.*)";
89 Pattern pnProtocol = Pattern.compile(regex);
90 Matcher maProtocol = pnProtocol.matcher(rawUrl);
91
92 if (maProtocol.matches() && maProtocol.groupCount() == 3) {
93 this.setProtocol(maProtocol.group(1));
94 rawUrl = maProtocol.group(3);
95
96 }
97
98 Pattern pnPort = Pattern.compile("(:)([0-9]{2,4})");
99 Matcher maPort = pnPort.matcher(rawUrl);
100 if (maPort.find()) {
101 this.setPort(maPort.group(2));
102 rawUrl = rawUrl.replace(":" + this.getPort(), "");
103 }
104
105 if (rawUrl.length() == 0) {
106 return;
107 }
108
109 String strHost = rawUrl.split("/")[0];
110 this.setHost(strHost);
111 rawUrl = rawUrl.replace(strHost, "");
112
113
114 if (rawUrl != null && rawUrl.length() > 0) {
115 this.setPath(rawUrl);
116 }
117
118
119 }
120
121
122 /**

Callers 1

UrlMethod · 0.95

Calls 7

setQueryMethod · 0.95
setProtocolMethod · 0.95
setPortMethod · 0.95
getPortMethod · 0.95
setHostMethod · 0.95
setPathMethod · 0.95
lengthMethod · 0.80

Tested by

no test coverage detected