{"id":13995193,"url":"https://github.com/Dashlane/SwiftDomainParser","last_synced_at":"2025-07-22T21:32:15.146Z","repository":{"id":42187893,"uuid":"142161966","full_name":"Dashlane/SwiftDomainParser","owner":"Dashlane","description":"A Full Swift Lightweight Framework that uses the Public Suffix list to Parse URLs ","archived":false,"fork":false,"pushed_at":"2024-01-03T14:39:02.000Z","size":154,"stargazers_count":61,"open_issues_count":0,"forks_count":20,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-04-25T15:02:35.822Z","etag":null,"topics":["parse","parseurl","psl","public-suffix-list","swift"],"latest_commit_sha":null,"homepage":null,"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/Dashlane.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2018-07-24T13:24:46.000Z","updated_at":"2024-07-18T03:10:38.003Z","dependencies_parsed_at":"2024-01-03T15:44:34.535Z","dependency_job_id":"d8895058-4dff-4900-b897-4991584a3b51","html_url":"https://github.com/Dashlane/SwiftDomainParser","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dashlane%2FSwiftDomainParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dashlane%2FSwiftDomainParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dashlane%2FSwiftDomainParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dashlane%2FSwiftDomainParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dashlane","download_url":"https://codeload.github.com/Dashlane/SwiftDomainParser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177812,"owners_count":17743170,"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","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":["parse","parseurl","psl","public-suffix-list","swift"],"created_at":"2024-08-09T14:03:17.813Z","updated_at":"2024-11-29T17:31:11.456Z","avatar_url":"https://github.com/Dashlane.png","language":"Swift","readme":"# Domain Parser\n![Platforms](https://img.shields.io/badge/Platforms-iOS_macOS-blue.svg?style=flat)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://github.com/Dashlane/SwiftDomainParser/blob/master/LICENSE)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift_Package_Manager-compatible-4BC51D.svg?style=flat)](https://www.swift.org/package-manager/)\n\n\nA full-Swift simple library which allows the parsing of hostnames, using the [Public Suffix List](https://publicsuffix.org).\n\nThis Library allows finding the ***domain name*** and the ***public suffix*** / ***top-level-domain*** for a given URL. \n\n\n## What is the Public Suffix List ?\n\nThe PSL lists all the known public suffixes (like: `com`, `co.uk`, `nt.edu.au`, ...). \nWithout this information we are not able to determine which part of a URL is the domain, since a suffix can have more than one Label. A suffix rule may also contain wildcards or exceptions to wildcards. If you want to understand the full format of PSL matching rules, you can read their specification [here](https://github.com/publicsuffix/list/wiki/Format#format).\n\nThe PSL is continuously updated.\n\nThe list includes ICANN suffixes (official top level domains) but also private suffixes (like `us-east-1.amazonaws.com`).\n\nExamples: \n\n| URL host                   | Domain          | Public suffix | Matched PSL rule | Explanation    |\n|---------------------------:|:---------------:|:-------------:|:----------------:|:---------------|\n| `auth.impala.dashlane.com` | `dashlane.com`  | `com`         | `com`            | Simple rule    |\n| `sub.domain.co.uk`         | `domain.co.uk`  | `co.uk`       | `co.uk`          | Simple rule    |\n| `sub.domain.gov.ck`        | `domain.gov.ck` | `gov.ck`      | `*.ck`           | Wildcard rule  |\n| `sub.domain.any.ck`        | `domain.any.ck` | `any.ck`      | `*.ck`           | Wildcard rule  |\n| `sub.sub.domain.any.ck`    | `domain.any.ck` | `any.ck`      | `*.ck`           | Wildcard rule  |\n| `www.ck`                   | `www.ck`        | `ck`          | `!www.ck`        | Exception rule |\n| `sub.www.ck`               | `www.ck`        | `ck`          | `!www.ck`        | Exception rule |\n| `sub.sub.www.ck`           | `www.ck`        | `ck`          | `!www.ck`        | Exception rule |\n\n\n## Usage \n\n#### Initialization: \n```\nimport DomainParser\n...\nlet domainParser = try DomainParser()\n```\n\nYou should use the same instance when you parse multiple URL hosts.\n\n``` \nlet domain: String? = domainParser.parse(host: \"awesome.dashlane.com\")?.domain\nprint(domain ?? \"N/A\") // dashlane.com\n```\n\n``` \nlet suffix1: String? = domainParser.parse(host: \"awesome.dashlane.com\")?.publicSuffix\nprint(suffix1 ?? \"N/A\") // com\n\nlet suffix2: String? = domainParser.parse(host: \"awesome.dashlane.co.uk\")?.publicSuffix\nprint(suffix2 ?? \"N/A\") // co.uk\n```\n\n## Update the local Public Suffix List \n\nThe local PSL used by the library is located at `DomainParser/DomainParser/Resources/public_suffix_list.dat`.\n\nTo update it, run this Terminal command in the `script` folder: \n``` \nswift UpdatePSL.swift \n```\n\n\n","funding_links":[],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDashlane%2FSwiftDomainParser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDashlane%2FSwiftDomainParser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDashlane%2FSwiftDomainParser/lists"}