@@ -7,7 +7,6 @@ import { IVectorStore } from "../interfaces/vector-store"
77import { Payload , VectorStoreSearchResult } from "../interfaces"
88import { DEFAULT_MAX_SEARCH_RESULTS , DEFAULT_SEARCH_MIN_SCORE } from "../constants"
99import { t } from "../../../i18n"
10- import { getGitRepositoryInfo } from "../../../utils/git"
1110
1211/**
1312 * Qdrant implementation of the vector store interface
@@ -102,7 +101,8 @@ export class QdrantVectorStore implements IVectorStore {
102101 if ( gitInfo ?. repositoryUrl ) {
103102 // Use repository URL to generate a deterministic name
104103 // This ensures the same collection name across worktrees and developers
105- const hash = createHash ( "sha256" ) . update ( gitInfo . repositoryUrl ) . digest ( "hex" )
104+ const normalizedUrl = this . normalizeGitUrl ( gitInfo . repositoryUrl )
105+ const hash = createHash ( "sha256" ) . update ( normalizedUrl ) . digest ( "hex" )
106106 return `repo-${ hash . substring ( 0 , 16 ) } `
107107 }
108108
@@ -158,9 +158,7 @@ export class QdrantVectorStore implements IVectorStore {
158158 const urlMatch = configContent . match ( / u r l \s * = \s * ( .+ ?) (?: \r ? \n | $ ) / m)
159159 if ( urlMatch && urlMatch [ 1 ] ) {
160160 const url = urlMatch [ 1 ] . trim ( )
161- // Normalize the URL to ensure consistency
162- const normalizedUrl = this . normalizeGitUrl ( url )
163- return { repositoryUrl : normalizedUrl }
161+ return { repositoryUrl : url }
164162 }
165163 }
166164 } catch ( error ) {
@@ -176,23 +174,40 @@ export class QdrantVectorStore implements IVectorStore {
176174 * @returns Normalized URL
177175 */
178176 private normalizeGitUrl ( url : string ) : string {
179- // Remove credentials
180- let normalized = url . replace ( / ^ h t t p s ? : \/ \/ [ ^ @ ] + @ / , "https://" )
181-
182- // Convert SSH to HTTPS format for consistency
183- if ( normalized . startsWith ( "git@" ) ) {
184- normalized = normalized . replace ( / ^ g i t @ ( [ ^ : ] + ) : / , "https://$1/" )
185- } else if ( normalized . startsWith ( "ssh://" ) ) {
186- normalized = normalized . replace ( / ^ s s h : \/ \/ (?: g i t @ ) ? ( [ ^ \/ ] + ) \/ / , "https://$1/" )
187- }
177+ try {
178+ // Remove credentials from HTTPS URLs
179+ let normalized = url
180+ if ( url . startsWith ( "https://" ) || url . startsWith ( "http://" ) ) {
181+ try {
182+ const urlObj = new URL ( url )
183+ urlObj . username = ""
184+ urlObj . password = ""
185+ normalized = urlObj . toString ( )
186+ } catch {
187+ // If URL parsing fails, just remove obvious credentials
188+ normalized = url . replace ( / ^ h t t p s ? : \/ \/ [ ^ @ ] + @ / , "https://" )
189+ }
190+ }
188191
189- // Remove .git suffix
190- normalized = normalized . replace ( / \. g i t $ / , "" )
192+ // Convert SSH to HTTPS format for consistency
193+ if ( normalized . startsWith ( "git@" ) ) {
194+ normalized = normalized . replace ( / ^ g i t @ ( [ ^ : ] + ) : / , "https://$1/" )
195+ } else if ( normalized . startsWith ( "ssh://" ) ) {
196+ normalized = normalized . replace ( / ^ s s h : \/ \/ (?: g i t @ ) ? ( [ ^ \/ ] + ) \/ / , "https://$1/" )
197+ }
198+
199+ // Remove .git suffix
200+ normalized = normalized . replace ( / \. g i t $ / , "" )
191201
192- // Convert to lowercase for consistency
193- normalized = normalized . toLowerCase ( )
202+ // Convert to lowercase for consistency
203+ normalized = normalized . toLowerCase ( )
194204
195- return normalized
205+ return normalized
206+ } catch ( error ) {
207+ // If normalization fails, return the original URL
208+ console . warn ( `[QdrantVectorStore] Could not normalize git URL:` , error )
209+ return url . toLowerCase ( )
210+ }
196211 }
197212
198213 /**
0 commit comments