File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -108,19 +108,32 @@ export default {
108108 new URL (url)
109109 return url
110110 } catch (e1) {
111- // If not, see whether we can find a URL at the end of this string.
112- // This happens when we share from the Amazon Shopping app.
113- const lastWord = url .trim ().split (' ' ).slice (- 1 )[0 ]
111+ // noop
112+ }
113+ // If not, see whether we can find a URL at the end of this string.
114+ // This happens e.g. when we share from the Amazon Shopping app.
115+ const lastWord = url .trim ().split (' ' ).slice (- 1 )[0 ]
116+ try {
117+ // eslint-disable-next-line no-new
118+ new URL (lastWord)
119+ // The last word is a URL - return it
120+ return lastWord
121+ } catch (e2) {
122+ // noop
123+ }
124+ const indexOfHttp = url .lastIndexOf (' http' )
125+ if (indexOfHttp > 0 ) {
126+ const couldBeUrl = url .substring (indexOfHttp)
114127 try {
115128 // eslint-disable-next-line no-new
116- new URL (lastWord)
117- // The last word is a URL - return it
118- return lastWord
119- } catch (e2) {
120- // We didn't find a valid URL - return our input unchanged
121- return url
129+ new URL (couldBeUrl)
130+ return couldBeUrl
131+ } catch (e3) {
132+ // noop
122133 }
123134 }
135+ // We didn't find a valid URL - return our input unchanged
136+ return url
124137 }
125138 }
126139}
You can’t perform that action at this time.
0 commit comments