Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1009 B
Go
43 lines
1009 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package oembed
|
|
|
|
import (
|
|
"net/url"
|
|
"regexp"
|
|
)
|
|
|
|
//go:generate go run ./generator/providers_generator.go
|
|
|
|
type ProviderEndpoint struct {
|
|
URL string
|
|
Patterns []*regexp.Regexp
|
|
}
|
|
|
|
func (e *ProviderEndpoint) GetProviderURL(requestURL string) string {
|
|
// This error is checked when generating the list of providers
|
|
url, _ := url.Parse(e.URL)
|
|
|
|
query := url.Query()
|
|
query.Add("format", "json")
|
|
query.Add("url", requestURL)
|
|
url.RawQuery = query.Encode()
|
|
|
|
return url.String()
|
|
}
|
|
|
|
// FindEndpointForURL returns a ProviderEndpoint for a given URL if it matches one that's supported by us. Returns nil
|
|
// if none of the supported providers match the given URL.
|
|
func FindEndpointForURL(requestURL string) *ProviderEndpoint {
|
|
for _, provider := range providers {
|
|
for _, pattern := range provider.Patterns {
|
|
if pattern.MatchString(requestURL) {
|
|
return provider
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|