Correct non existent domain name to nearest match - error-correction

I'm looking for a service that tells you the nearest match of a non existent domain, because it was misspelled by the user. For example, if an user writes 'hotmail.con', send a query with that and obtain as a result 'hotmail.com'.

You've picked a hard problem. A domain can be 1-63 characters long, shall contain characters [a-z0-9-], and shall not start with a hyphen. Brute forcing it not an option. If the user types in hotmail.con you could search misspellings of it, which would try homail.com and hotmale.com, which may or may not be accurate domain names, who is to know WHICH mis-spelling is the correct one? The computer would have to return a list of options to the user: "Did you mean this domain name, or maybe or that domain name?".
You might be interested in Peter Norvig's spelling corrector that Google uses to spell check queries that come in. It's one of the best spelling correctors on the planet.
http://norvig.com/spell-correct.html
Peter Norvig's Spell checker should work provided you had a body of correct domain names which is up to date. You could create your own list on the fly, by keeping a list of which sites the user has been to, and using those as the body of domain names to check against. That way, when the user selects "hotmail.con" it finds hotmail.com in your list. However, this does not protect the user from accidentally visiting: "hotmale.com". Because that is a valid site.
Here is a stackoverflow qustion about how to get all the domain names:
https://stackoverflow.com/questions/4539155/how-to-get-all-the-domain-names
The best idea is to think outside the box and do it like firefox does it. When the user starts typing hotmail.com, what they usually do is click a textbox, type "h", then "o". Have a dropdown come out with recently visited domain names that start with that.

Related

Case Insensitive Search parameters for API endpoint

I am working on a project that involves integrating the PUBG API. From my site, the player can lookup stats using their player name, platform and season. One issue I am facing is that the player name have to be exact and is case sensitive. Now I assumed it to be the case at the beginning. However, after searching for the name in this site I found that they don't need the name to be case sensitive. Also, referring to this post from the PUBG Dev community here I saw that it confirmed my initial assumption. So my question is if PUBG API requires the names to be case sensitive then, how is the site (linked) can search for the player even if the name provided is not in exact, matching case? For example,:
I looked up the player name MyCholula. From the PUBG API page for player lookup, it returns the proper value. When I tried mycholula, it doesn't and sends a 404. From the linked site above, both combination seems to work. Now if spaces or other separators were involved in the name then, it would be easy to convert it assuming that separated words are all capitalized (somewhat naive assumption though). For this name, I don't see any way of converting mycholula to MyCholula. I also tried many other combination in the linked site above (also different user names I got from my friends) to confirm that the linked site is actually returning the data as expected for any combination of user names. I also tried it on other sites like this and it didn't work just like it doesn't work from the PUBG DEV API page or from my page.
I am really confused as to how they are doing it. The only possible explanation I can come up with is that they have the player records stored in their database from where, they can perform advanced regexp based search to get the actual name. However, this sounds far fetched since, there are millions of players and it would require them to know all the player names and associated IDs. Also, as far as I know, it is not possible to use regex or other string manipulation to convert to the actual name because there can be many combinations (not an expert on regex so can't be definitive on this).
Any help or suggestions will be greatly appreciated. Thanks.

Use REGEX to generate multiple conversions per session in Google Analytics?

I've got a client with a real estate Website. Based on comparing goal completions to unique page views, it's pretty clear that some visitors inquire about multiple properties during a single session (more unique pages matching the REGEX string than completed goals). As goal tracking is set-up now, only one conversion per session is being completed (which I know is standard for GA).
I am using the destination as the confirmation of goal completion.
"Thank you" pages for conversions look like this:
/Enquiry/Thank-You/?subject=B30794&market=sale
/Enquiry/Thank-You/?subject=B36930&market=rental
My goal tracking REGEX is \Q/Enquiry/Thank-You/\E
I'm pretty sure that I can get Google Analytics to count more than one "thank you" as a completed goal during a session if I can account for the variable in the middle (B30794, B36930, etc.) plus the sale or rental on the end of the URL
I've asked around, including Google's GA community but can't get an string that works to handle the variable in the middle. These are two tags recommended to me that have not worked:
This string returns zero results:
^/Enquiry/Thank-You/\?subject=.*&market=(sale|rental)$
This string returns more than simply the thank you URLs:
^/Enquiry/Thank-You/\?subject=.*&market=sale|rental$
Try this one, the issue for the empty one was that the characters were not escaped:
^\/Enquiry\/Thank\-You\/\?subject=.*&market=(sale|rental)$

Are all URLs discoverable? Can you hide information safely in a random URL?

I've been wondering about this for a while.
Let's say I have a web application at
www.example.com
If there are n users of the application, could each person login simply using a URL?
E.g. For user 1 to access their part of the application, they would visit
www.example.com/user/1
In this above case, the URL scheme is easily guessed.
But what if it can't be easily guessed?
E.g. For user 1 to access their part of the application, they would visit
www.example.com/user/[random string]
Are these random URLs discover-able?
What I mean by random URL is a URL containing a very long string of random characters. If one used this URL as a password, it would be very difficult to guess.
And secondly, a more practical question--
Can one assume that no one else has access to their part of the application?
Or another way of asking, is guessing a random string the only way of accessing someone's part of the application?
The motivation for designing an application this way is that there would be no login/logout required.
Thanks
Even if you put a random string in place of a user id, the same problem still exists. If someone guesses or somehow retrieves the random number of another user, he or she will still be able to access it.
What you are attempting is called security through obscurity. It is not a good plan to have your overall security based on hiding or obscuring sensitive data only.
Are these random URLs discover-able?
Discoverable by search engine? That depends on your website settings.
Accessible? Yes.
Can one assume that no one else has access to their part of the application?
I am not sure what you meant by this, you will have clarify this part.

Regular Expressions - Parsing Domain Issues

I am trying to find the domain -- everything but the subdomain.
I have this regexp right now:
(?:[-a-zA-Z0-9]+\.)*([-a-zA-Z0-9]+(?:\.[a-zA-Z]{2,3})){1,2}
This works for things like:
domain.tld
subdomain.tld
But it runs into trouble with tld's like ".com.au" or ".co.uk":
domain.co.uk (finds co.uk, should find domain.co.uk)
subdomain.domain.co.uk (finds co.uk, should find domain.co.uk)
Any ideas?
I'm not sure this problem is "reasonably solvable"; Mozilla maintains a list of 'public suffix' domains that is intended to help browser authors accept cookies for only domains within one administrative control (e.g., prevent someone from setting a cookie valid for *.co.uk. or *.union.aero.). It obviously isn't perfect (near the end, you'll find a long list of is-a-caterer.com-style domains, so foo.is-a-caterer.com couldn't set a cookie that would be used by bar.is-a-caterer.com, but is-a-caterer.com is perfectly well a "domain" as you've defined it.)
So, if you're prepared to use the list as provided, you could write a quick little parser that would know how to apply the general rules and exceptions to determine where in the given input string your "domain" comes, and return just the portion you're interested in.
I think simpler approaches are doomed to failure: some ccTLDs such as .ca don't use second-level domains, some such as .br use dozens, and some, like lib.or.us are several levels away from the "domain" such as multnomah.lib.or.us. Unless you're using curated lists of which domains are a public suffix, you're doomed to being wrong for some non-trivial set of input strings.

Match all characters in group except for first and last occurrence

Say I request
parent/child/child/page-name
in my browser. I want to extract the parent, children as well as page name. Here are the regular expressions I am currently using. There should be no limit as to how many children there are in the url request. For the time being, the page name will always be at the end and never be omitted.
^([\w-]{1,}){1} -> Match parent (returns 'parent')
(/(?:(?!/).)*[a-z]){1,}/ -> Match children (returns /child/child/)
[\w-]{1,}(?!.*[\w-]{1,}) -> Match page name (returns 'page-name')
The more I play with this, the more I feel how clunky this solution is. This is for a small CMS I am developing in ASP Classic (:(). It is sort of like the MVC routing paths. But instead of calling controllers and functions based on the URL request. I would be travelling down the hierarchy and finding the appropriate page in the database. The database is using the nested set model and is linked by a unique page name for each child.
I have tried using the split function to split with a / delimiter however I found I was nested so many split statements together it became very unreadable.
All said, I need an efficient way to parse out the parent, children as well as page name from a string. Could someone please provide an alternative solution?
To be honest, I'm not even sure if a regular expression is the best solution to my problem.
Thank you.
You could try using:
^([\w-]+)(/.*/)([\w-]+)$
And then access the three matching groups created using Match.SubMatches. See here for more details.
EDIT
Actually, assuming that you know that [\w-] is all that is used in the names of the parts, you can use ^([\w-]+)(.*)([\w-]+)$ instead and it will handle the no-child case fine by itself as well.