kanimaru / twitcher

Full Twitch Library for Godot
MIT License
65 stars 9 forks source link

use generell url parser. #33

Open lublak opened 3 months ago

lublak commented 3 months ago

Currently the code uses the same regex multiple times:

func get_authorization_host() -> String:
    var matches = url_regex.search(authorization_url)
    if matches == null: return ""
    return matches.get_string(1)

func get_authorization_path() -> String:
    var matches = url_regex.search(authorization_url)
    if matches == null: return ""
    return matches.get_string(6)

a better solution could be a "URL" class.

just a quick note:

class Url {
  port
  host
  path
  ....
  new() {

  }

  static fromString(url string) {
     // use regex to fill props
  }
}
kanimaru commented 3 months ago

I wonder why godot doesn't have such a class already.

lublak commented 3 months ago

@kanimaru I think, most of the time, it's not needed in game development. In which game do you need a URL parser? Okay yes, now it would be useful xD

kanimaru commented 3 months ago

All games with multiplayer support via REST? :D

lublak commented 3 months ago

Touché! xD but I think with the native Godot client you could use the full URL address without splitting it into host and path. So most of the time, nobody needs to split it.