{"id":15293644,"url":"https://github.com/gumob/tldextractswift","last_synced_at":"2025-10-09T17:33:37.876Z","repository":{"id":56922943,"uuid":"158196159","full_name":"gumob/TLDExtractSwift","owner":"gumob","description":"A pure Swift library to allows you to get the public suffix of a domain name","archived":false,"fork":false,"pushed_at":"2025-06-22T13:26:53.000Z","size":638,"stargazers_count":32,"open_issues_count":1,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-09T17:32:17.219Z","etag":null,"topics":["carthage","idna","ios","macos","punycode","swift-package-manager","swift5","tvos","visionos","watchos"],"latest_commit_sha":null,"homepage":"https://gumob.github.io/TLDExtractSwift/swiftdoc/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gumob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["gumob"]}},"created_at":"2018-11-19T09:36:08.000Z","updated_at":"2025-06-22T13:26:57.000Z","dependencies_parsed_at":"2024-05-02T06:35:10.833Z","dependency_job_id":"657d68ff-8bb4-449a-a520-5de9264cfc76","html_url":"https://github.com/gumob/TLDExtractSwift","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/gumob/TLDExtractSwift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumob%2FTLDExtractSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumob%2FTLDExtractSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumob%2FTLDExtractSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumob%2FTLDExtractSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gumob","download_url":"https://codeload.github.com/gumob/TLDExtractSwift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumob%2FTLDExtractSwift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001865,"owners_count":26083197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","idna","ios","macos","punycode","swift-package-manager","swift5","tvos","visionos","watchos"],"created_at":"2024-09-30T16:50:22.507Z","updated_at":"2025-10-09T17:33:37.858Z","avatar_url":"https://github.com/gumob.png","language":"Swift","funding_links":["https://github.com/sponsors/gumob"],"categories":[],"sub_categories":[],"readme":"[![Swift Package Manager compatible](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange)](https://github.com/gumob/TLDExtractSwift)\n![Carthage](https://img.shields.io/badge/Carthage-Compatible-blue)\n[![Cocoapods Version](https://img.shields.io/cocoapods/v/TLDExtractSwift.svg)](https://cocoapods.org/pods/TLDExtractSwift)\n[![Cocoapods Platform](https://img.shields.io/cocoapods/p/TLDExtractSwift.svg)](https://cocoadocs.org/docsets/TLDExtract)\n[![Build](https://github.com/gumob/TLDExtractSwift/actions/workflows/main.yml/badge.svg)](https://github.com/gumob/TLDExtractSwift/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/gumob/TLDExtractSwift/branch/master/graph/badge.svg)](https://codecov.io/gh/gumob/TLDExtractSwift)\n![Language](https://img.shields.io/badge/Language-Swift%205.0-orange.svg)\n![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)\n\n# TLDExtract\n\u003ccode\u003eTLDExtract\u003c/code\u003e is a pure Swift library to allows you to get the public suffix of a domain name using [the Public Suffix List](http://www.publicsuffix.org). You can find alternatives for other languages at [publicsuffix.org](https://publicsuffix.org/learn/).\u003cbr/\u003e\n\n## What are domains?\n\nDomain names are the unique, human-readable Internet addresses of websites. They are made up of three parts: a top-level domain (a.k.a. TLD), a second-level domain name, and an optional subdomain.\n\n\u003cimg src=\"https://raw.githubusercontent.com/gumob/TLDExtractSwift/main/Metadata/domain-diagram.webp\" alt=\"drawing\" width=\"100%\" style=\"width:100%; max-width: 100%;\"/\u003e\n\n## Changes in 3.0.0\n\n### Breaking changes\n\n- ‼️ Library name changed from ~~`TLDExtract`~~ to **`TLDExtractSwift`** to resolve namespace conflicts. For more details, please check the issue ([apple/swift#56573](https://github.com/apple/swift/issues/56573)).\n  \n  Please don't forget to update your source code.\n\n  ```diff\n  - import TLDExtract\n  + import TLDExtractSwift\n  ```\n\n### Other changes\n- Dropped support for Swift 4.\n- Added watchOS and visionOS to supported platforms.\n- Changed supported versions for macOS, iOS, and tvOS to match Xcode 15.4.\n\n\n## Feature\n\n- Extract root domain, top level domain, second level domain, subdomain from url and hostname\n- Foundation URL and String support\n- IDNA support\n- Multi platform support\n\n## Requirements\n\n- macOS 10.13 or later\n- iOS 12.0 or later\n- tvOS 12.0 or later\n- watchOS 4.0 or later\n- visionOS 1.0 or later\n- Swift 5.0 or later\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file.\n\n- macOS, iOS, tvOS, watchOS, visionOS, and Swift 5\n\n    ```swift\n    dependencies: [\n        .package(url: \"https://github.com/gumob/TLDExtractSwift.git\", .upToNextMajor(from: \"3.0.0\"))\n    ]\n    ```\n\n- macOS, iOS, tvOS, and Swift 5\n\n    ```swift\n    dependencies: [\n        .package(url: \"https://github.com/gumob/TLDExtractSwift.git\", .upToNextMajor(from: \"2.1.1\"))\n    ]\n    ```\n\n### Carthage\n\nAdd the following to your `Cartfile` and follow [these instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).\n\n- macOS, iOS, tvOS, watchOS, visionOS, and Swift 5\n\n    ```\n    github \"gumob/TLDExtractSwift\" ~\u003e 3.0\n    ```\n- macOS, iOS, tvOS, and Swift 5\n\n    ```\n    github \"gumob/TLDExtractSwift\" ~\u003e 2.0\n    ```\n- macOS, iOS, tvOS, and Swift 4\n\n    ```\n    github \"gumob/TLDExtractSwift\" ~\u003e 1.0\n    ```\n\nDo not forget to include Punycode.framework. Otherwise it will fail to build the application.\u003cbr/\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/gumob/TLDExtractSwift/main/Metadata/carthage-xcode-config.jpg\" alt=\"drawing\" width=\"480\" style=\"width:100%; max-width: 480px;\"/\u003e\n\n### CocoaPods\n\nTo integrate TLDExtract into your project, add the following to your `Podfile`.\n\n- macOS, iOS, tvOS, watchOS, visionOS, and Swift 5.0\n\n    ```ruby\n    pod 'TLDExtractSwift', '~\u003e 3.0'\n    ```\n- macOS, iOS, tvOS, and Swift 5.0\n\n    ```ruby\n    pod 'TLDExtract', '~\u003e 2.0'\n    ```\n- macOS, iOS, tvOS, and Swift 4.2\n\n    ```ruby\n    pod 'TLDExtract', '~\u003e 1.0'\n    ```\n\n## Usage\n\nFull documentation is available at [https://gumob.github.io/TLDExtractSwift/swiftdoc/](https://gumob.github.io/TLDExtractSwift/swiftdoc/).\n\n### Initialization\n\nBasic initialization code. Exceptions will not be raised unless [the Public Suffix List on the server](https://publicsuffix.org/list/public_suffix_list.dat) is broken.\n\n```swift\nimport TLDExtractSwift\n\nlet extractor = try! TLDExtract()\n```\n\nA safer initialization code to avoid errors by using the frozen Public Suffix List:\u003cbr/\u003e\n\n```swift\nimport TLDExtractSwift\n\nlet extractor = try! TLDExtract(useFrozenData: true)\n\n```\n*The Public Suffix List is updated every time the framework is built. By setting userFrozenData to true, TLDExtract loads data which checked out from the repository.\n\n### Extraction\n\n#### Passing argument as String\n\nExtract an url:\n\n```swift\nlet urlString: String = \"https://www.github.com/gumob/TLDExtract\"\nguard let result: TLDResult = extractor.parse(urlString) else { return }\n\nprint(result.rootDomain)        // Optional(\"github.com\")\nprint(result.topLevelDomain)    // Optional(\"com\")\nprint(result.secondLevelDomain) // Optional(\"github\")\nprint(result.subDomain)         // Optional(\"www\")\n```\n\nExtract a hostname:\n\n```swift\nlet hostname: String = \"gumob.com\"\nguard let result: TLDResult = extractor.parse(hostname) else { return }\n\nprint(result.rootDomain)        // Optional(\"gumob.com\")\nprint(result.topLevelDomain)    // Optional(\"com\")\nprint(result.secondLevelDomain) // Optional(\"gumob\")\nprint(result.subDomain)         // nil\n```\n\nExtract an unicode hostname:\n\n```swift\nlet hostname: String = \"www.ラーメン.寿司.co.jp\"\nguard let result: TLDResult = extractor.parse(hostname) else { return }\n\nprint(result.rootDomain)        // Optional(\"寿司.co.jp\")\nprint(result.topLevelDomain)    // Optional(\"co.jp\")\nprint(result.secondLevelDomain) // Optional(\"寿司\")\nprint(result.subDomain)         // Optional(\"www.ラーメン\")\n```\n\nExtract a punycoded hostname (Same as above):\n\n```swift\nlet hostname: String = \"www.xn--4dkp5a8a.xn--sprr0q.co.jp\")\"\nguard let result: TLDResult = extractor.parse(hostname) else { return }\n\nprint(result.rootDomain)        // Optional(\"xn--sprr0q.co.jp\")\nprint(result.topLevelDomain)    // Optional(\"co.jp\")\nprint(result.secondLevelDomain) // Optional(\"xn--sprr0q\")\nprint(result.subDomain)         // Optional(\"www.xn--4dkp5a8a\")\n```\n\n#### Passing argument as Foundation URL\n\nExtract an unicode url: \u003cbr/\u003e\nURL class in Foundation Framework does not support unicode URLs by default. You can use URL extension as a workaround\n\n```swift\nlet urlString: String = \"http://www.ラーメン.寿司.co.jp\"\nlet url: URL = URL(unicodeString: urlString)\nguard let result: TLDResult = extractor.parse(url) else { return }\n\nprint(result.rootDomain)        // Optional(\"www.ラーメン.寿司.co.jp\")\nprint(result.topLevelDomain)    // Optional(\"co.jp\")\nprint(result.secondLevelDomain) // Optional(\"寿司\")\nprint(result.subDomain)         // Optional(\"www.ラーメン\")\n```\n\nEncode an url by passing argument as percent encoded string (Same as above):\n\n```swift\nlet urlString: String = \"http://www.ラーメン.寿司.co.jp\".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!\nlet url: URL = URL(string: urlString)\nprint(urlString)                // http://www.%E3%83%A9%E3%83%BC%E3%83%A1%E3%83%B3.%E5%AF%BF%E5%8F%B8.co.jp\n\nguard let result: TLDResult = extractor.parse(url) else { return }\n\nprint(result.rootDomain)        // Optional(\"www.ラーメン.寿司.co.jp\")\nprint(result.topLevelDomain)    // Optional(\"co.jp\")\nprint(result.secondLevelDomain) // Optional(\"寿司\")\nprint(result.subDomain)         // Optional(\"www.ラーメン\")\n```\n\nEncode an unicode url by using [`Punycode`](https://github.com/gumob/Punycode) Framework:\n\n```swift\nimport Punycode\n\nlet urlString: String = \"http://www.ラーメン.寿司.co.jp\".idnaEncoded!\nlet url: URL = URL(string: urlString)\nprint(urlString)                // http://www.xn--4dkp5a8a.xn--sprr0q.co.jp\n\nguard let result: TLDResult = extractor.parse(url) else { return }\n\nprint(result.rootDomain)        // Optional(\"xn--sprr0q.co.jp\")\nprint(result.topLevelDomain)    // Optional(\"co.jp\")\nprint(result.secondLevelDomain) // Optional(\"xn--sprr0q\")\nprint(result.subDomain)         // Optional(\"www.xn--4dkp5a8a\")\n```\n\n## Copyright\n\nTLDExtract is released under MIT license, which means you can modify it, redistribute it or use it however you like.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgumob%2Ftldextractswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgumob%2Ftldextractswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgumob%2Ftldextractswift/lists"}