Skip to content

Conversation

@TheSeeker
Copy link
Contributor

Bookmarks may not point to the root of a site, so use regex to construct the activelink instead of blindly tacking activelink.png at the end.

This assumes activelinks are always in the root.

@Bombe
Copy link
Contributor

Bombe commented Oct 22, 2023

Yeah, you’re not gonna sneak that one in without a test. 😄

Regex was too greedy, matched last instance of what looks like an edition isntead of the first.
@ArneBab
Copy link
Contributor

ArneBab commented Oct 27, 2023

Our build system seems unhappy about Capitalized Case.

@Bombe
Copy link
Contributor

Bombe commented Oct 27, 2023

Uh, yeah, as should have been @TheSeeker’s IDE?! Because that’s not valid Java…

fix Switch/Case -> switch/case
fix missing parens.
fix scope issue.
Copy link
Contributor

@Bombe Bombe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the test is still missing! 🙂

// extract the key type
String keyType = initialKey.substring(1,3);
String key = '/' + initialKey + (initialKey.endsWith("/") ? "" : "/");
Matcher match = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing that match is not used anywhere outside the two branches within the switch statement, I believe “fix scope issue” and this change are diametrally opposed. 😀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the switch branches share the scope, so that’s how it has to be to avoid inventing new names for the different branches.

String initialKey = item.getKey();
String key = '/' + initialKey + (initialKey.endsWith("/") ? "" : "/") + "activelink.png";
// extract the key type
String keyType = initialKey.substring(1,3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has to go from 0 to 3 — Java is zero-indexed.

switch (keyType) {
case "USK":
case "SSK":
match = PATTERN_USK_SSK.matcher(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only matches when the key is already well-formed ⇒ ideally extract to a static method (uses no this; just put static before the function name to compiler-check that), and write a test that takes the existing bookmarks as input (and maybe some bad but valid examples) and returns the correct key for the activelink.

@ArneBab
Copy link
Contributor

ArneBab commented Jul 25, 2024

I agree very much that we need this fix (thank you!), but the current implementation is still buggy. A test just for the key adjustment should make this much easier to develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants