Skip to content

Commit 2e65672

Browse files
committed
Merge branch 'release/1.0.4'
2 parents 497584d + 8564386 commit 2e65672

File tree

14 files changed

+116
-13
lines changed

14 files changed

+116
-13
lines changed

domino-history-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.dominokit</groupId>
66
<artifactId>domino-history</artifactId>
7-
<version>1.0.3</version>
7+
<version>1.0.4</version>
88
</parent>
99
<packaging>gwt-lib</packaging>
1010
<modelVersion>4.0.0</modelVersion>

domino-history-client/src/main/java/org/dominokit/domino/client/history/StateHistory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,15 @@ public void invoke() {
411411
*/
412412
@Override
413413
public void fireCurrentStateHistory(String title) {
414-
415414
fireStateInternal(StateToken.of(windowToken()).title(title).data(stateData(windowState())));
416415
}
417416

417+
@Override
418+
public void reload() {
419+
Location location = Js.uncheckedCast(DomGlobal.location);
420+
location.reload();
421+
}
422+
418423
private void fireStateInternal(StateToken stateToken) {
419424
EffectiveToken effectiveToken = new EffectiveToken(rootPath, stateToken);
420425
replaceState(effectiveToken);

domino-history-jvm/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>domino-history</artifactId>
77
<groupId>org.dominokit</groupId>
8-
<version>1.0.3</version>
8+
<version>1.0.4</version>
99
</parent>
1010
<packaging>jar</packaging>
1111
<modelVersion>4.0.0</modelVersion>

domino-history-jvm/src/main/java/org/dominokit/domino/client/history/JVMHistory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,11 @@ public void invoke() {
384384
}
385385
}
386386

387+
@Override
388+
public void reload() {
389+
fireCurrentStateHistory();
390+
}
391+
387392
private class JVMState implements State {
388393

389394
private final HistoryState historyState;

domino-history-shared/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>domino-history</artifactId>
77
<groupId>org.dominokit</groupId>
8-
<version>1.0.3</version>
8+
<version>1.0.4</version>
99
</parent>
1010
<packaging>gwt-lib</packaging>
1111
<modelVersion>4.0.0</modelVersion>

domino-history-shared/src/main/java/org/dominokit/domino/history/DominoHistory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ default boolean isInformOnPopState() {
159159

160160
void removeInterceptor(HistoryInterceptor interceptor);
161161

162+
void reload();
163+
162164
/** A functional interface to define a listener to be called when url state is changed. */
163165
interface StateListener {
164166
/**

domino-history-shared/src/main/java/org/dominokit/domino/history/HistoryToken.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ public interface HistoryToken {
155155
*/
156156
HistoryToken replaceAllPaths(String newPath);
157157

158+
/**
159+
* Remove all paths that appear after the specified path element
160+
*
161+
* @param offsetPath the path to remove its tailing paths, the specified offsetPath won't be
162+
* removed.
163+
* @return {@link HistoryToken} with its path part being ends with the specified offsetPath.
164+
*/
165+
HistoryToken removePathTail(String offsetPath);
166+
158167
/**
159168
* Removes the whole path part of the {@link HistoryToken}
160169
*

domino-history-shared/src/main/java/org/dominokit/domino/history/StateHistoryToken.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,21 @@ public HistoryToken replaceAllPaths(String newPath) {
514514
return this;
515515
}
516516

517+
/**
518+
* Remove all paths that appear after the specified path element
519+
*
520+
* @param offsetPath the path to remove its tailing paths, the specified offsetPath won't be
521+
* removed.
522+
* @return {@link HistoryToken} with its path part being ends with the specified offsetPath.
523+
*/
524+
@Override
525+
public HistoryToken removePathTail(String offsetPath) {
526+
while (!endsWithPath(offsetPath)) {
527+
removeLastPath();
528+
}
529+
return this;
530+
}
531+
517532
/**
518533
* Replace the whole token fragment part with the newFragment
519534
*

domino-history-shared/src/main/java/org/dominokit/domino/history/TokenFilter.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,11 @@ class ContainsFragmentFilter implements TokenFilter {
366366

367367
@Override
368368
public boolean filter(HistoryToken token) {
369-
return token.fragment().contains(matchingPart);
369+
String unHashed = TokenUtil.unHashFragment(this.matchingPart);
370+
if (unHashed.isEmpty()) {
371+
return false;
372+
}
373+
return token.fragment().contains(unHashed);
370374
}
371375

372376
@Override
@@ -380,7 +384,7 @@ public NormalizedToken normalizeToken(String rootPath, String token) {
380384
}
381385

382386
/**
383-
* A token filter that will return <b>true</b> only if the history token fargment part is an exact
387+
* A token filter that will return <b>true</b> only if the history token fragment part is an exact
384388
* match of the specified part.
385389
*/
386390
class ExactFragmentFilter implements TokenFilter {
@@ -392,7 +396,11 @@ class ExactFragmentFilter implements TokenFilter {
392396

393397
@Override
394398
public boolean filter(HistoryToken token) {
395-
return token.fragment().equals(matchingPart);
399+
String unHashed = TokenUtil.unHashFragment(this.matchingPart);
400+
if (unHashed.isEmpty()) {
401+
return false;
402+
}
403+
return token.fragment().equals(unHashed);
396404
}
397405

398406
@Override
@@ -414,7 +422,11 @@ class StartsWithFragmentFilter implements TokenFilter {
414422

415423
@Override
416424
public boolean filter(HistoryToken token) {
417-
return token.fragment().startsWith(prefix);
425+
String unHashed = TokenUtil.unHashFragment(this.prefix);
426+
if (unHashed.isEmpty()) {
427+
return false;
428+
}
429+
return token.fragment().startsWith(unHashed);
418430
}
419431

420432
@Override
@@ -436,7 +448,11 @@ class EndsWithFragmentFilter implements TokenFilter {
436448

437449
@Override
438450
public boolean filter(HistoryToken token) {
439-
return token.fragment().endsWith(postfix);
451+
String unHashed = TokenUtil.unHashFragment(this.postfix);
452+
if (unHashed.isEmpty()) {
453+
return false;
454+
}
455+
return token.fragment().endsWith(unHashed);
440456
}
441457

442458
@Override
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright © 2019 Dominokit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.dominokit.domino.history;
17+
18+
public class TokenUtil {
19+
20+
public static String unHashFragment(String fragment) {
21+
if (fragment.contains("#")) {
22+
int lastHashIndex = fragment.lastIndexOf("#");
23+
if (fragment.length() > lastHashIndex + 1) {
24+
return fragment.substring(lastHashIndex + 1);
25+
} else {
26+
return "";
27+
}
28+
}
29+
return fragment;
30+
}
31+
}

0 commit comments

Comments
 (0)