Closed minaguib closed 11 years ago
hrm that's actually a really good idea. on vacation at the moment. won't be back til like... october really. happy to get something like this though. unsure about edge cases but yeah as is isn't optimal.
Cool. I'll whip something up.
Question for discussion.
Currently, there's some unpredictable behavior for dot handling:
irb(main):012:0> "a.b".to_url
=> "a-dot-b"
irb(main):013:0> "a.b.c".to_url
=> "a-dot-b-c"
Is this intentional or buggy ? I came across it in my own branch which implements handling for abbreviations:
irb(main):004:0> "Match the D.N.A.".to_url
=> "match-the-dna"
irb(main):005:0> "Go to the Y.M.C.America".to_url
=> "go-to-the-y-dot-m-c-dot-america"
How do you think that last example would be best URLified ?
first should be a-dot-b-dot-c. definitely bug. YMCAmerica is prolly just that. i've only heard it called YMCA mostly though. but i guess it's the same pattern with the word spelled out too, yeah?
@minaguib Still working on this? Would love a fix...
@minaguib i'm back from vacation land if i can pitch on this. trying to get some improvements into Stringex lately and this one is definitely one i'd love to have in the next gem release [prolly next week]. lemme know if there's anything i can do to help or whatever.
Hey
I've had this https://github.com/minaguib/stringex/commit/d36c35273b318d44909b2285b683553571d2edc0 done for a while.
As you can see it's much better than before, however since I discovered the anomaly (as posted above in the discussion and added explicitly in the test suite "Go to the Y.M.C.America"), I haven't had time to go back and fix that case in the old code.
Unfortunately I won't have time the next few days to work on it. If anyone would like to attack the anomaly I pointed out you're more than welcome to.
i'll pull this into a branch and mess around with getting that bug out. awesome.
is this the expected transliteration for you?
"Go to the Y.M.C.America" =>
"go-to-the-ymcamerica",
i've got passing tests on that if so ready to go.
if not... oh boy ;)
check out https://github.com/rsl/stringex/tree/dotbug if you want to play around with it. or lemme know if it's mergeable. would love to push it to master.
gonna go ahead and merge this. seems as good as anything. could go back and forth on how that should go. thanks on this.
I understand the reasoning behind something like "google.com" -> "google dot com"
However, I feel that for abbreviations, "D.N.A." would be better converted to "dna"
Yay/nay ? I'd be happy to work on and submit a patch.