normalize instance uri
This commit is contained in:
parent
2c4504bad3
commit
0702703d78
|
@ -99,7 +99,7 @@ public class AccountSession{
|
|||
public Uri getInstanceUri() {
|
||||
return new Uri.Builder()
|
||||
.scheme("https")
|
||||
.authority(getInstance().map(i -> i.uri).orElse(domain))
|
||||
.authority(getInstance().map(i -> i.normalizedUri).orElse(domain))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ public class InstanceRulesFragment extends ToolbarFragment implements ProvidesAs
|
|||
private ElevationOnScrollListener onScrollListener;
|
||||
|
||||
private static final int RULES_REQUEST=376;
|
||||
private String domain;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState){
|
||||
|
@ -63,10 +62,6 @@ public class InstanceRulesFragment extends ToolbarFragment implements ProvidesAs
|
|||
super.onAttach(activity);
|
||||
setNavigationBarColor(UiUtils.getThemeColor(activity, R.attr.colorWindowBackground));
|
||||
instance=Parcels.unwrap(getArguments().getParcelable("instance"));
|
||||
// akkoma says uri is "https://example.social" while just "example.social" on mastodon
|
||||
domain = instance.uri
|
||||
.replaceFirst("^https://", "")
|
||||
.replaceFirst("/$", "");
|
||||
setTitle(R.string.instance_rules_title);
|
||||
}
|
||||
|
||||
|
@ -142,7 +137,7 @@ public class InstanceRulesFragment extends ToolbarFragment implements ProvidesAs
|
|||
public void onProvideAssistContent(AssistContent assistContent) {
|
||||
assistContent.setWebUri(new Uri.Builder()
|
||||
.scheme("https")
|
||||
.authority(domain)
|
||||
.authority(instance.normalizedUri)
|
||||
.path("/about")
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -88,6 +88,9 @@ public class Instance extends BaseModel{
|
|||
|
||||
public PleromaPollLimits pollLimits;
|
||||
|
||||
/** like uri, but always without scheme and trailing slash */
|
||||
public transient String normalizedUri;
|
||||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
super.postprocess();
|
||||
|
@ -97,6 +100,10 @@ public class Instance extends BaseModel{
|
|||
rules=Collections.emptyList();
|
||||
if(shortDescription==null)
|
||||
shortDescription="";
|
||||
// akkoma says uri is "https://example.social" while just "example.social" on mastodon
|
||||
normalizedUri = uri
|
||||
.replaceFirst("^https://", "")
|
||||
.replaceFirst("/$", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue