java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.URL
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
JavaScript host object for
URL.- Author:
- Ahmed Ashour, Ronald Brill, cd alexndr, Lai Quang Duong
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateObjectURL(Object fileOrBlob) The URL.createObjectURL() static method creates aDOMStringcontaining a URL representing the object given as parameter.getDefaultValue(Class<?> hint) Returns the default string representation of this URL.getHash()Returns the hash portion of the URL, containing a#followed by the fragment identifier.getHost()Returns the host portion of the URL, consisting of the hostname and, if the port is non-empty, a:followed by the port.Returns the hostname portion of the URL.getHref()Returns the full URL as a string.Returns the origin of the URL.Returns the password specified before the domain name.Returns the pathname portion of the URL.getPort()Returns the port number of the URL, or an empty string if no explicit port is specified.Returns the protocol scheme of the URL, including the trailing:.Returns the query string, containing a?followed by the URL's parameters.Returns aURLSearchParamsobject providing access to the decoded query arguments of the URL.Returns the username specified before the domain name.voidjsConstructor(String url, Object base) Creates an instance of this object.Returns the URL as a string.static voidrevokeObjectURL(org.htmlunit.corejs.javascript.Scriptable objectURL) Revokes ablob:URL, removing its entry from the blob URL store.voidSets thehashproperty.voidSets thehostproperty.voidsetHostname(String hostname) Sets thehostnameproperty.voidSets thehrefproperty, navigating to the new URL.voidsetPassword(String password) Sets thepasswordproperty.voidsetPathname(String path) Sets thepathnameproperty.voidSets theportproperty.voidsetProtocol(String protocol) Sets theprotocolproperty.voidSets thesearchproperty.voidsetSearch(List<NameValuePair> nameValuePairs) Sets thesearchproperty from a list ofNameValuePairs.voidsetUsername(String username) Sets theusernameproperty.toJSON()Returns a serialized version of the URL.Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
URL
public URL()
-
-
Method Details
-
jsConstructor
Creates an instance of this object.- Parameters:
url- a string representing an absolute or relative URL. Ifurlis a relative URL,baseis required and will be used as the base URL. Ifurlis an absolute URL, a givenbasewill be ignored.base- a string representing the base URL to use whenurlis a relative URL. If not specified, it defaults to''.
-
createObjectURL
The URL.createObjectURL() static method creates aDOMStringcontaining a URL representing the object given as parameter. The new object URL represents the specifiedFileobject orBlobobject and is registered in theuser-agent-wide blob URL store, so it can be resolved from any document of the same client. -
revokeObjectURL
public static void revokeObjectURL(org.htmlunit.corejs.javascript.Scriptable objectURL) Revokes ablob:URL, removing its entry from the blob URL store.- Parameters:
objectURL- the object URL previously returned bycreateObjectURL(Object)- See Also:
-
getHash
Returns the hash portion of the URL, containing a#followed by the fragment identifier.- Returns:
- the hash portion of the URL, or an empty string if there is no fragment
-
setHash
Sets thehashproperty.- Parameters:
fragment- the new hash value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getHost
Returns the host portion of the URL, consisting of the hostname and, if the port is non-empty, a:followed by the port.- Returns:
- the host
-
setHost
Sets thehostproperty.- Parameters:
host- the new host value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getHostname
Returns the hostname portion of the URL.- Returns:
- the hostname
-
setHostname
Sets thehostnameproperty.- Parameters:
hostname- the new hostname value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getHref
Returns the full URL as a string.- Returns:
- the full URL
-
setHref
Sets thehrefproperty, navigating to the new URL.- Parameters:
href- the new URL string- Throws:
MalformedURLException- if the URL is malformed
-
getOrigin
Returns the origin of the URL.- Returns:
- the origin
-
getSearchParams
Returns aURLSearchParamsobject providing access to the decoded query arguments of the URL.- Returns:
- the search params
-
getPassword
Returns the password specified before the domain name.- Returns:
- the password, or an empty string if none is specified
-
setPassword
Sets thepasswordproperty.- Parameters:
password- the new password value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getPathname
Returns the pathname portion of the URL.- Returns:
- the pathname
-
setPathname
Sets thepathnameproperty.- Parameters:
path- the new pathname value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getPort
Returns the port number of the URL, or an empty string if no explicit port is specified.- Returns:
- the port, or an empty string
-
setPort
Sets theportproperty.- Parameters:
port- the new port value, or an empty string to remove the port- Throws:
MalformedURLException- if the resulting URL is malformed
-
getProtocol
Returns the protocol scheme of the URL, including the trailing:.- Returns:
- the protocol
-
setProtocol
Sets theprotocolproperty.- Parameters:
protocol- the new protocol value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getSearch
Returns the query string, containing a?followed by the URL's parameters.- Returns:
- the search string, or an empty string if none
-
setSearch
Sets thesearchproperty.- Parameters:
search- the new search string- Throws:
MalformedURLException- if the resulting URL is malformed
-
setSearch
Sets thesearchproperty from a list ofNameValuePairs.- Parameters:
nameValuePairs- the pairs to encode as the query string- Throws:
MalformedURLException- if the resulting URL is malformed
-
getUsername
Returns the username specified before the domain name.- Returns:
- the username, or an empty string if none is specified
-
setUsername
Sets theusernameproperty.- Parameters:
username- the new username value- Throws:
MalformedURLException- if the resulting URL is malformed
-
getDefaultValue
Returns the default string representation of this URL.- Specified by:
getDefaultValuein interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
getDefaultValuein classHtmlUnitScriptable- Parameters:
hint- the type hint- Returns:
- the URL as a string
- See Also:
-
toJSON
Returns a serialized version of the URL. In practice this is equivalent tojsToString().- Returns:
- the serialized URL string
-
jsToString
Returns the URL as a string.- Returns:
- the URL string
-