Skip to content

Commit

Permalink
Implemented URI::compare
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuswatn committed Feb 12, 2017
1 parent 7a0e93f commit e52bde0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/iruleuri.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace eval ::testcl::URI {
namespace export protocol
namespace export query
namespace export path
namespace export compare

}

Expand Down Expand Up @@ -201,3 +202,30 @@ proc ::testcl::URI::path {uri {start ""} {end ""}} {
return $path
}

proc ::testcl::URI::compare {uri1 uri2} {
log::log debug "URI::compare $uri1 $uri2 invoked"

if { [string tolower [protocol $uri1]] ne [string tolower [protocol $uri2]] } {
log::log debug "URI::compare returning false because the protocols do not match"
return 0
} elseif { [string tolower [host $uri1]] ne [string tolower [host $uri2]] } {
log::log debug "URI::compare returning false because the hosts do not match"
return 0
} elseif { [port $uri1] ne [port $uri2] } {
log::log debug "URI::compare returning false because the ports do not match"
return 0
} elseif { [path $uri1] ne [path $uri2] } {
log::log debug "URI::compare returning false because the paths do not match"
return 0
} elseif { [basename $uri1] ne [basename $uri2] } {
log::log debug "URI::compare returning false because the basenames do not match"
return 0
} elseif { [query $uri1] ne [query $uri2] } {
log::log debug "URI::compare returning false because the query strings do not match"
return 0
} else {
log::log debug "URI::compare returning true, as all the checks passed"
return 1
}
}

0 comments on commit e52bde0

Please sign in to comment.