utils_test.go 636 B

1234567891011121314151617181920
  1. package desktop
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. // 解析路径中的 :id 字段
  7. func TestParseId(t *testing.T) {
  8. fmt.Println(ParsePathParam("/nginx/10", "/nginx/:id"))
  9. fmt.Println(ParsePathParam("/nginx/1/refresh", "/nginx/:id/refresh"))
  10. fmt.Println(ParsePathParam("/nginx/134/refresh", "/nginx/:id/refresh"))
  11. fmt.Println(ParsePathParam("/nginx/125/http/refresh", "/nginx/:id/http/refresh"))
  12. fmt.Println(ParsePathParam("/nginx/125/http/refresh", "/nginx/:id/http"))
  13. fmt.Println(ParsePathParam("/nginx/125/admin/http/refresh", "/nginx/:id/:user/http/refresh"))
  14. fmt.Println(ParsePathParam("/nginx/123/wew/789", "/nginx/:id"))
  15. }