4

I am trying to find more about custom URL mapping Schemes associated with a certain app. I checked a few SO discussions but have not been able to conclude. I have a few questions for URL Scheme Mapping,

  1. Is there a way (like a certain command or a file that stores this info) to get a list of URL Schemes and the applications they map to on a given Apple iPhone or Mac? (I am guessing the answer is no - based on https://stackoverflow.com/a/10951866/1165727 but I want to confirm since this answer is quite old).

  2. Is running "strings" command on an app the only way to find out the URL schemes that are associated with the app? (This is based on the comments to this answer - https://stackoverflow.com/a/5707825/1165727).

  3. Is there a more complete list of URL Schemes than - http://wiki.akosma.com/IPhone_URL_Schemes

Community
  • 1
  • 1
Y123
  • 915
  • 13
  • 30

2 Answers2

13

On OS X, you can use:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump

That shows the dump of the Launch Services database, which includes URL schemes and their mappings to apps.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • This doesn't cover everything though. The answer on this [post](https://superuser.com/a/548122/402911) offers two more alternatives to display more results. That command, for example, doesn't show that you can use `dict:\\` the dictionary app – Clifford Fajardo May 12 '19 at 22:22
2

Here is a one-line script which uses Perl to parse the data from the LaunchServices database, based on the answer by Ken Thomases.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | LC_ALL=C tr '\n' '\a' | perl -pe 's/(-{20}\aBundleClass)/\n\1/g' | perl -e 'sub trim {my $s = shift; $s =~ s/\a//g; $s =~ s/\"//g; $s =~ s/\{//g; $s =~ s/\}//g; $s =~ s/^\s+|\s+$//g; return $s}; sub trimCommas {my $s = shift; $s =~ s/,//g; return $s}; while ($line = <STDIN>) {if (index($line, "CFBundleURLTypes = ") != -1) {$urlTypesData = $line; $urlTypesData =~ s/^.*CFBundleURLTypes = .*?\((.*?)[^es] =.*$/\1/g; $urlTypesData =~ s/(^.*)\).*?$/\1/g; @urlTypes = split("}", $urlTypesData); if (trim($urlTypesData) ne "" && int(@urlTypes) > 1) {$name1 = $path = (split("CFBundleExecutable", $line))[0]; $name1 =~ s/.*name:(.*?)\a.*$/\1/g; $name2 = $line; $name2 =~ s/^.*CFBundleExecutable = (.*?)\;.*$/\1/g; $appName = ((index($name1, "(null)") == -1) ? trim($name1) : trim($name2)); $path =~ s/.*path:(.*?)\a.*$/\1/g; print $appName . "\f   " . "\033[38;5;173m(path: " . trim($path) . ")\033(B\033[m"; for ($i=0; $i<int(@urlTypes)-1; $i++) {$curUrlName = @urlTypes[$i]; if (index(@urlTypes[$i], "CFBundleURLName") != -1) {$curUrlName =~ s/^.*CFBundleURLName =(.*?);.*$/\1/} else {$curUrlName = "\e[3m[Blank]\e[0m"}; $schemesRaw = @urlTypes[$i]; $schemesRaw =~ s/^.*CFBundleURLSchemes =.*?\((.*?)\).*$/\1/g; @schemes = split(",", $schemesRaw); if (trimCommas(trim(@urlTypes[$i])) ne "") {print "\f\t" . trimCommas(trim($curUrlName)); for ($b=0; $b<int(@schemes); $b++) {print "\f\t\t" . trim(@schemes[$b])}}; print "\f"}}; print "\n"}}' | sort -uf | perl -pe 's/(\n)/\1\1\1/g; s/\f/\n/g'

Here is a few lines of the output:

command output

htmlcat
  • 336
  • 3
  • 10