Смотреть в Telegram
👩‍💻 تکه‌ کد اعتبارسنجی لینک [Url] ⚠️ این تکه کد به زبان ⚫️ نوشته شده است
package main

import (
 "fmt"
 "net/url"
 "strings"
)

func isValidUrl(input string) bool {
 decodedUrl, err := url.QueryUnescape(input)
 if err != nil {
  return false
 }

 parsedUrl, err := url.Parse(decodedUrl)
 if err != nil || len(decodedUrl) >= 2048 {
  return false
 }

 lowerUrl := strings.ToLower(decodedUrl)
 if strings.Contains(decodedUrl, "../") || strings.Contains(lowerUrl, "javascript:") || strings.Contains(lowerUrl, "<script>") {
  return false
 }

 if parsedUrl.Host != "" && !strings.Contains(parsedUrl.Host, ".") {
  return false
 }

 return true
}


func main() {
// Example
fmt.Println(isValidUrl("https://hero"))
// Output: false 
fmt.Println(isValidUrl("https://hero.ac"))
// Output: true
}
✈️ @HeroExpert_ir | کارشناس قهرمان
Please open Telegram to view this post
VIEW IN TELEGRAM
Love Center - Dating, Friends & Matches, NY, LA, Dubai, Global
Love Center - Dating, Friends & Matches, NY, LA, Dubai, Global
Бот для знакомств