moduleNetwork.Shpider.URL(moduleNetwork.URL,isSameDomain,mkAbsoluteUrl,isAbsoluteUrl,isMailto,isHttp,getDomain,getFolder)whereimportNetwork.URLimportNetwork.Shpider.StateimportText.Regex.PosiximportNetwork.Shpider.TextUtils-- | is the second url on the same domain as the first? Note: this will return False if either URL is invalid.isSameDomain::String->String->BoolisSameDomainurlYourOnurlYourNot=leturl1=importURLurlYourOnurl2=importURLurlYourNotinmaybeFalse(\t1->maybeFalse(\t2->leturlType1=url_typet1urlType2=url_typet2isRelativeut=(ut==PathRelative)||(ut==HostRelative)ut1Relative=isRelativeurlType1ut2Relative=isRelativeurlType2utsSame=urlType1==urlType2in(ut1Relative||ut2Relative||utsSame))url2)url1-- | Assumes the given URL is relative to `currentPage`.mkAbsoluteUrl::String->Shpider(MaybeString)mkAbsoluteUrluncleanUrl=doifnot$isMailtouncleanUrlthendoshpider<-getletcleanUrlStr=escapeSpacesuncleanUrlmaybeUrl=importURLcleanUrlStrcurrentAddr=addr$currentPageshpidermaybe(returnNothing)(\url->caseurl_typeurlofPathRelative->return$Just$getFoldercurrentAddr++urlStrHostRelative->return$Just$getDomaincurrentAddr++urlStr_->return$JusturlStr)maybeUrlelsereturnNothingwhereurlStr=escapeSpacesuncleanUrl-- | True if the url is absoluteisAbsoluteUrl::String->BoolisAbsoluteUrlurlStr=caseimportURLurlStrofJusturl->caseurl_typeurlofAbsolute_->True_->False_->False-- | is the given string of form \"mailto:person.com\"?isMailto::String->BoolisMailto=flip(=~)"mailto:.*"-- | is the url a http url?isHttp::String->BoolisHttp=flip(=~)"(http://|https://).*"-- | Get the protocol and domain from a URL eg---- @-- getDomain \"widdle:\/\/owqueer.co.uk\/strangeanticsofsailors\/jimmy\"-- -- \"widdle:\/\/owqueer.co.uk\"-- @getDomain::String->StringgetDomain=flip(=~)"[^:]+://[^/]+"-- | Get the whole url up to and including the current folder of the present document.-- -- @ -- getFolder \"widdle:\/\/owqueer.co.uk\/strangeanticsofsailors\/jimmy\"-- -- \"widdle:\/\/owqueer.co.uk\/strangeanticsofsailors\/\"-- @getFolder::String->StringgetFolderurl=letms=url=~"[^/]*/[^/]*"l=lengthmsinifl>0then(concat$take(l-1)$mapheadms)++"/"else""