Skip to content

Commit a390781

Browse files
committed
internalLinks [nfc]: Pull out some parsedUrl variables, with comments
1 parent e8fae2e commit a390781

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/utils/internalLinks.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ import { isUrlOnRealm } from './url';
2828
// like the web app's parse_narrow in static/js/hash_util.js.
2929
// TODO(#3757): Use @zulip/shared for that parsing.
3030
const getHashSegmentsFromNarrowLink = (url: string, realm: URL) => {
31-
const result = new URL(url, realm).hash
31+
// TODO: Get this from caller
32+
const parsedUrl = new URL(url, realm);
33+
34+
const result = parsedUrl.hash
3235
.split('/')
3336
// Remove the first item, "#narrow".
3437
.slice(1);
@@ -66,7 +69,10 @@ type LinkType = 'non-narrow' | 'home' | 'pm' | 'topic' | 'stream' | 'special';
6669
// TODO: Work out what this does, write a jsdoc for its interface, and
6770
// reimplement using URL object (not just for the realm)
6871
export const getLinkType = (url: string, realm: URL): LinkType => {
69-
if (!isNarrowLink(new URL(url, realm), realm)) {
72+
// TODO: Get this from caller
73+
const parsedUrl = new URL(url, realm);
74+
75+
if (!isNarrowLink(parsedUrl, realm)) {
7076
return 'non-narrow';
7177
}
7278

0 commit comments

Comments
 (0)