Skip to content

Commit 06299b2

Browse files
committed
cleanup
1 parent 42545b7 commit 06299b2

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/main/java/org/htmlunit/javascript/host/Location.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,14 @@ public void setSearch(final String search) throws Exception {
361361
* @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a>
362362
*/
363363
public String getHash() {
364-
String hash = hash_;
365-
366-
if (hash_ != null) {
367-
hash = decodeHash(hash);
364+
if (StringUtils.isEmptyOrNull(hash_)) {
365+
return "";
368366
}
369367

370-
if (StringUtils.isEmptyOrNull(hash)) {
371-
// nothing to do
368+
if (hash_.indexOf('%') == -1) {
369+
return "#" + UrlUtils.encodeHash(hash_);
372370
}
373-
else {
374-
return "#" + UrlUtils.encodeHash(hash);
375-
}
376-
377-
return "";
371+
return "#" + UrlUtils.encodeHash(UrlUtils.decode(hash_));
378372
}
379373

380374
private String getHash(final boolean encoded) {
@@ -434,13 +428,6 @@ public void setHash(final String oldURL, String hash, final boolean triggerHashC
434428
}
435429
}
436430

437-
private static String decodeHash(final String hash) {
438-
if (hash.indexOf('%') == -1) {
439-
return hash;
440-
}
441-
return UrlUtils.decode(hash);
442-
}
443-
444431
/**
445432
* Returns the hostname portion of the location URL.
446433
* @return the hostname portion of the location URL

0 commit comments

Comments
 (0)