2022-10-24 15:06:49 +00:00
|
|
|
package components
|
|
|
|
|
|
|
|
type Location struct {
|
|
|
|
*Directive
|
|
|
|
Modifier string
|
|
|
|
Match string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLocation(directive *Directive) *Location {
|
|
|
|
location := &Location{
|
|
|
|
Modifier: "",
|
|
|
|
Match: "",
|
|
|
|
Directive: directive,
|
|
|
|
}
|
|
|
|
if directive.GetBlock() != nil {
|
|
|
|
directive.Comment = directive.GetBlock().GetComment()
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(directive.Parameters) == 0 {
|
|
|
|
panic("no enough parameter for location")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(directive.Parameters) == 1 {
|
|
|
|
location.Match = directive.Parameters[0]
|
|
|
|
return location
|
|
|
|
} else if len(directive.Parameters) == 2 {
|
|
|
|
location.Match = directive.Parameters[1]
|
2023-04-12 13:52:30 +00:00
|
|
|
location.Modifier = directive.Parameters[0]
|
2022-10-24 15:06:49 +00:00
|
|
|
return location
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|