diff --git a/src/modules/suggestions/utilities/delimiters.ts b/src/modules/suggestions/utilities/delimiters.ts index 25cdf5bd4..c2f173882 100644 --- a/src/modules/suggestions/utilities/delimiters.ts +++ b/src/modules/suggestions/utilities/delimiters.ts @@ -27,9 +27,24 @@ const delimiters: Delimiters = { function getLastDelimiterInUrl(url: string): Delimiter { const symbols = Object.values(delimiters); symbols.forEach(key => { - key.index = url.lastIndexOf(key.symbol); + const prevCharIndex = url.lastIndexOf(key.symbol) - 1; + key.index = isSecondLastCharADelimiter(url.charAt(prevCharIndex)) ? url.lastIndexOf(key.symbol)-1 : + url.lastIndexOf(key.symbol); }); + return symbols.reduce((prev, current) => (prev.index > current.index) ? prev : current); } +const isSecondLastCharADelimiter = (prevCharacter: string): boolean => { + const symbols = Object.values(delimiters); + let isSecondLastCharDelimiter = false; + for(const symbol of symbols ){ + if(prevCharacter === symbol.symbol){ + isSecondLastCharDelimiter = true; + break; + } + } + return isSecondLastCharDelimiter; +} + export { delimiters, getLastDelimiterInUrl } \ No newline at end of file