mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-16 16:34:21 +00:00
fix: spotify regex pattern
Fix regex pattern to use non-capturing group for optional intl prefix in Spotify track URLs
This commit is contained in:
parent
8f1ab855a2
commit
1daf682062
1 changed files with 2 additions and 2 deletions
|
|
@ -183,9 +183,9 @@ func isValidPattern(url, pattern string) bool {
|
|||
}
|
||||
|
||||
func TrackInfo(url string) (*Track, error) {
|
||||
re := regexp.MustCompile(`open\.spotify\.com\/track\/([a-zA-Z0-9]{22})`)
|
||||
re := regexp.MustCompile(`open\.spotify\.com\/(?:intl-.+\/)?track\/([a-zA-Z0-9]{22})(\?si=[a-zA-Z0-9]{16})?`)
|
||||
matches := re.FindStringSubmatch(url)
|
||||
if len(matches) != 2 {
|
||||
if len(matches) <= 2 {
|
||||
return nil, errors.New("invalid track URL")
|
||||
}
|
||||
id := matches[1]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue