MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / jsConstructor

Method jsConstructor

src/main/java/org/htmlunit/javascript/host/URL.java:60–81  ·  view source on GitHub ↗

Creates an instance. @param url a string representing an absolute or relative URL. If url is a relative URL, base is required, and will be used as the base URL. If url is an absolute URL, a given base will be ignored. @param base a string representing the base URL to use in case url

(final String url, final Object base)

Source from the content-addressed store, hash-verified

58 * is a relative URL. If not specified, it defaults to ''.
59 */
60 @JsxConstructor
61 @JsxConstructorAlias(alias = "webkitURL")
62 public void jsConstructor(final String url, final Object base) {
63 String baseStr = null;
64 if (!JavaScriptEngine.isUndefined(base)) {
65 baseStr = JavaScriptEngine.toString(base);
66 }
67
68 try {
69 if (org.htmlunit.util.StringUtils.isBlank(baseStr)) {
70 url_ = UrlUtils.toUrlUnsafe(url);
71 }
72 else {
73 final java.net.URL baseUrl = UrlUtils.toUrlUnsafe(baseStr);
74 url_ = UrlUtils.toUrlUnsafe(UrlUtils.resolveUrl(baseUrl, url));
75 }
76 url_ = UrlUtils.removeRedundantPort(url_);
77 }
78 catch (final MalformedURLException e) {
79 throw JavaScriptEngine.typeError(e.toString());
80 }
81 }
82
83 /**
84 * The URL.createObjectURL() static method creates a DOMString containing a URL

Callers

nothing calls this directly

Calls 8

isUndefinedMethod · 0.95
toStringMethod · 0.95
toUrlUnsafeMethod · 0.95
resolveUrlMethod · 0.95
removeRedundantPortMethod · 0.95
typeErrorMethod · 0.95
isBlankMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected