Skip to content

Commit c40fe4e

Browse files
committed
add file// prefix to navigate tool
1 parent 346909a commit c40fe4e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

common/src/util/string.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,22 @@ export const snakeToTitleCase = (str: string): string => {
155155
* Uses http:// for localhost and local IPs, https:// for all other domains
156156
*/
157157
export const ensureUrlProtocol = (url: string): string => {
158-
if (url.startsWith('http://') || url.startsWith('https://')) {
158+
if (
159+
url.startsWith('http://') ||
160+
url.startsWith('https://') ||
161+
url.startsWith('file://')
162+
) {
159163
return url
160164
}
161165

162166
if (url.startsWith('localhost') || url.match(/^127\.\d+\.\d+\.\d+/)) {
163167
return `http://${url}`
164168
}
165169

170+
if (url.startsWith('/')) {
171+
return `file://${url}`
172+
}
173+
166174
return `https://${url}`
167175
}
168176

0 commit comments

Comments
 (0)