Skip to content

Commit cc6e3cb

Browse files
committed
internal_link [nfc]: Explain wrinkle in same-origin check
1 parent 8a9c39e commit cc6e3cb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/model/internal_link.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ bool _sameOrigin(Uri url, Uri realmUrl) {
171171
try {
172172
return url.origin == realmUrl.origin;
173173
} on StateError {
174+
// The getter [Uri.origin] throws if the scheme is not "http" or "https".
175+
// (Also if the URL is relative or certain kinds of malformed, but those
176+
// should be impossible as `url` came from [PerAccountStore.tryResolveUrl]).
177+
// In that case `url` has no "origin", and certainly not the realm's origin.
174178
return false;
175179
}
176180
}

0 commit comments

Comments
 (0)