{"id":48611225,"url":"https://github.com/weroro-sk/sms-href","last_synced_at":"2026-04-09T00:34:33.715Z","repository":{"id":68997164,"uuid":"604390656","full_name":"weroro-sk/sms-href","owner":"weroro-sk","description":"SMS Href creates SMS URL strings, updates existing SMS URL strings, or updates all href attributes containing SMS URLs on a web page or in a defined DOM context.","archived":false,"fork":false,"pushed_at":"2025-01-22T22:43:58.000Z","size":6120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-09T16:32:25.516Z","etag":null,"topics":["android","deep-link","front-end","frontend","generate","hypertext","ios","mobile","sms","sms-href","sms-link","sms-protocol","tablet","typescript","web","weroro"],"latest_commit_sha":null,"homepage":"https://weroro-sk.github.io/sms-href/demo/","language":"TypeScript","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/weroro-sk.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":"2023-02-21T00:44:40.000Z","updated_at":"2025-01-22T22:44:01.000Z","dependencies_parsed_at":"2024-04-03T05:30:52.436Z","dependency_job_id":null,"html_url":"https://github.com/weroro-sk/sms-href","commit_stats":{"total_commits":30,"total_committers":1,"mean_commits":30.0,"dds":0.0,"last_synced_commit":"cfb7681a2a1bb07c3ae1eb7ceb4e17c4b8d66efd"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/weroro-sk/sms-href","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weroro-sk%2Fsms-href","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weroro-sk%2Fsms-href/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weroro-sk%2Fsms-href/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weroro-sk%2Fsms-href/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weroro-sk","download_url":"https://codeload.github.com/weroro-sk/sms-href/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weroro-sk%2Fsms-href/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31580187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["android","deep-link","front-end","frontend","generate","hypertext","ios","mobile","sms","sms-href","sms-link","sms-protocol","tablet","typescript","web","weroro"],"created_at":"2026-04-09T00:34:33.252Z","updated_at":"2026-04-09T00:34:33.657Z","avatar_url":"https://github.com/weroro-sk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\u003cpicture\u003e\n\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"sms-href_logo.svg\"\u003e\n\u003csource media=\"(prefers-color-scheme: light)\" srcset=\"sms-href_logo.svg\"\u003e\n\u003cimg alt=\"SMS Href\" align=\"top\" height=\"40px\" src=\"sms-href_logo.svg\"\u003e\n\u003c/picture\u003e SMS Href\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  SMS Href creates SMS URL strings, updates existing SMS URL strings, or updates all href attributes containing SMS URLs on a web page or in a defined DOM context.\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n\n  \u003ca href=\"https://www.npmjs.com/package/sms-href\" target=\"_blank\" title=\"Latest NPM version\"\u003e\n    \u003cimg alt=\"NPM version\" src=\"https://img.shields.io/npm/v/sms-href?label=npm%20version\u0026style=flat-square\u0026logo=npm\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/weroro-sk/sms-href\" target=\"_blank\" title=\"Latest package.json version on GitHub\"\u003e\n    \u003cimg alt=\"GitHub version\" src=\"https://img.shields.io/github/package-json/version/weroro-sk/sms-href/main?label=github%20version\u0026style=flat-square\u0026logo=github\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/weroro-sk/sms-href/releases\" target=\"_blank\"\u003e\n    \u003cimg alt=\"GitHub release (latest by date)\" src=\"https://img.shields.io/github/v/release/weroro-sk/sms-href?label=github%20release\u0026style=flat-square\u0026logo=github\"\u003e\n  \u003c/a\u003e\n\n  \u003cimg alt=\"demo\" src=\"https://img.shields.io/badge/Webpack_build_size-\u003c_1.81_kB-orange?style=flat-square\u0026logo=webpack\"\u003e\n\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://weroro-sk.github.io/sms-href/demo/\" target=\"_blank\" title=\"Try out SMS Href on your mobile device\"\u003e\n    \u003cimg alt=\"demo\" src=\"https://img.shields.io/badge/Try_SMS_Href-Live_demo-green?style=for-the-badge\u0026logo=github\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n\u003e You can avoid this library and use the universal separator `;?\u0026` (all three characters in that order),\n\u003e but it doesn't work everywhere.\n\n---\n\n- [Installation](#installation)\n- [Usage](#basic-usage-without-catching-outputs)\n- [API](#api)\n    - [Instance](#instance)\n        - [Custom separator](#custom-separator-definition)\n    - [fixAll](#fixall)\n    - [fixValue](#fixvalue)\n    - [create](#create)\n- [Types](#types)\n    - [ResultCode](#resultcode)\n    - [Options](#options)\n    - [Devices](#devices)\n    - [SmsConfiguration](#smsconfiguration)\n\n---\n\n---\n\n## Installation\n\n| Manager                                                                                                                                                                                   | Command                |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|\n| \u003cimg width=\"60px\" src=\"https://upload.wikimedia.org/wikipedia/commons/d/db/Npm-logo.svg\" alt=\"NPM\"\u003e                                                                                       | `npm install sms-href` |\n| \u003cimg width=\"60px\" src=\"https://raw.githubusercontent.com/yarnpkg/assets/76d30ca2aebed5b73ea8131d972218fb860bd32d/yarn-kitten-full.svg\" alt=\"YARN\"\u003e                                        | `yarn add sms-href`    |\n| \u003cimg width=\"60px\" src=\"https://d33wubrfki0l68.cloudfront.net/aad219b6c931cebb53121dcda794f6180d9e4397/17f34/assets/images/pnpm-standard-79c9dbb2e99b8525ae55174580061e1b.svg\" alt=\"PNPM\"\u003e | `pnpm add sms-href`    |\n| \u003cimg width=\"60px\" src=\"https://bun.sh/logo.svg\" alt=\"BUN\"\u003e                                                                                                                                | `bun add sms-href`     |\n\n## \u003cimg height=\"20px\" src=\"https://upload.wikimedia.org/wikipedia/commons/d/db/Npm-logo.svg\" alt=\"NPM\"\u003e DEV runners\n\n| runner               | output                                  | description                               |\n|----------------------|-----------------------------------------|-------------------------------------------|\n| `npm run build`      | `./lib/**/*`                            | Transpile from Typescript to Javascript   |\n| `npm run build:pack` | `./sms-href-{package-json-version}.tgz` | Create NPM package file (`*.tgz`)         |\n| `npm run demo`       | `./demo/dist/demo.js`                   | Build demo and measure minimal build size |\n\n## Basic usage (without catching outputs)\n\n```typescript\nimport {SmsHref} from \"sms-href\";\n\nconst smsHref: SmsHref = new SmsHref();\n\n// As promise\nsmsHref.fixAll().catch();\n\n// OR sync\ntry {\n    await smsHref.fixAll();\n} catch (e) {\n}\n\n```\n\n## Tested platforms\n\n| Android          | iOS       | iPadOS    |\n|------------------|-----------|-----------|\n| 10 (Quince Tart) | 6         | 6         |\n| 12 (Snow Cone)   | 8         | 8         |\n| 13 (Tiramisu)    | 12        | 12        |\n|                  | 15        | 15        |\n|                  | 16        | 16        |\n|                  | 17 (beta) | 17 (beta) |\n\n---\n\n## API\n\n### Instance\n\nSyntax:\n\n#### ``` new SmsHref( [ options: Options ] ) ```\n\nInstance of `SmsHref`\n\nExample:\n\n```typescript\nconst smsHref: SmsHref = new SmsHref();\n```\n\nConstructor parameters:\n\n|                                    | type                  | default | description                                                                                                                                                                                                                                          |\n|------------------------------------|-----------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`options`]                        | [`Options`](#options) |         | Configuration of custom separator and allowed devices - [Show detail](#options)                                                                                                                                                                      |\n| [`options.allow`]                  | [`Devices`](#devices) |         | List of enable/disable devices - [Show detail](#devices)                                                                                                                                                                                             |\n| [`options.allow.mobile` = true ]   | `boolean`             | `true`  | Enable/disable href update for mobile devices                                                                                                                                                                                                        |\n| [`options.allow.tablet` = true ]   | `boolean`             | `true`  | Enable/disable href update for tablet devices                                                                                                                                                                                                        |\n| [`options.allow.facebook` = true ] | `boolean`             | `true`  | Enable/disable href update for Facebook app web view                                                                                                                                                                                                 |\n| [`options.separator` = null ]      | `string` `null`       | `null`  | User defined SMS body (`body=`) separator. [Read more](#custom-separator-definition) \u003cbr/\u003e**NOTE**: Internal platform detection and allowed devices list will be disabled.                                                                           |\n| [`options.encode` = true ]         | `boolean`             | `true`  | Enable/disable message text encoding globally ( e.g., `encodeURIComponent` )\u003cbr/\u003e**NOTE**: Methods [fixValue()](#fixvalue) and [create()](#create) have their own parameter for enable/disable encoding and this global parameter can be overridden. |\n\nExample (disable tablets and facebook app web view):\n\n```typescript\nconst smsHref: SmsHref = new SmsHref({\n    allow: {\n        facebook: false,\n        tablet: false\n    }\n});\n```\n\n### Custom separator definition\n\nIf you want to define your own separator, you can use existed separator constants\n\n| constant name                | value | type     | description                                                                            |\n|------------------------------|-------|----------|----------------------------------------------------------------------------------------|\n| `ANDROID_SEPARATOR`          | `?`   | `string` | Body separator `?body=` for `Android` platform                                         |\n| `IOS_7_AND_LOWER_SEPARATOR`  | `;`   | `string` | Body separator `;body=` for `IOS \u003c= 7` platform                                        |\n| `IOS_8_AND_HIGHER_SEPARATOR` | `\u0026`   | `string` | Body separator `\u0026body=` for `IOS \u003e= 8` platform                                        |\n| `MIN_IOS_VERSION`            | `7`   | `number` | Value is **`7`** - because **`iOS7`** allegedly doesn't support **`sms:`** href links. |\n\n**NOTE:** `IOS 7` allegedly does not support `sms:` protocol.\n\nExample:\n\n```typescript\nimport {\n    SmsHref,\n    MIN_IOS_VERSION,\n    ANDROID_SEPARATOR,\n    IOS_7_AND_LOWER_SEPARATOR,\n    IOS_8_AND_HIGHER_SEPARATOR\n} from \"sms-href\";\n\n// Custom\nfunction customSeparatorMechanism(): string | null {\n    const platform: CustomPlatformDetection = new CustomPlatformDetection();\n\n    if (platform.name === 'Android')\n        return ANDROID_SEPARATOR;\n\n    if (platform.name === 'IOS') {\n        if (platform.version.major \u003c= MIN_IOS_VERSION)\n            return IOS_7_AND_LOWER_SEPARATOR\n        return IOS_8_AND_HIGHER_SEPARATOR;\n    }\n\n    return null;\n}\n\n// Instance\nconst smsHref: SmsHref = new SmsHref({\n    separator: customSeparatorMechanism()\n});\n```\n\n---\n\n### fixAll\n\nSyntax:\n\n#### ``` async fixAll( [ context: Element | HTMLElement | Document ] ) : Promise\u003cResultCode\u003e ```\n\nFinds and update all anchor links with `sms:` protocol value by current platform in set DOM context.\n\n|                         | type                               | default    | description                        |\n|-------------------------|------------------------------------|------------|------------------------------------|\n| [`context` = document ] | `Element` `HTMLElement` `Document` | `document` | Defines parent DOM node for search |\n| returns                 | `Promise\u003cResultCode\u003e`              |            |                                    |\n| throws                  | `Promise.catch\u003cResultCode\u003e`        |            |                                    |\n\nExample:\n\n```typescript\nawait smsHref.fixAll();\n```\n\nExample with custom defined context:\n\n```typescript\nconst context: HTMLElement = document.querySelector('.context-element');\n\nawait smsHref.fixAll(context);\n```\n\nExample with using `resultCode` in `Promise\u003cResultCode\u003e`.\n\n```typescript\nimport {\n    SmsHref,\n    ResultCode,\n    CODE_SUCCESS,\n    CODE_NOT_FOUND,\n    CODE_UNSUPPORTED_OS\n} from \"sms-href\";\n\nconst smsHref: SmsHref = new SmsHref();\n\nsmsHref.fixAll()\n    .then((resultCode: ResultCode): void =\u003e {\n        if (resultCode === CODE_SUCCESS)\n            console.log(`All sms: href values in anchors was updated`);\n    })\n    .catch((resultCode: any): void =\u003e {\n        if (resultCode === CODE_NOT_FOUND)\n            console.log(`'Anchors with sms: href value doesn't exist'`);\n        else if (resultCode === CODE_UNSUPPORTED_OS)\n            console.log(`Current platform doesn't support sms: href protocol`);\n    });\n```\n\n[ResultCode](#resultcode) constants list:\n\n| constant name         | value | type     | status              | description                                         |\n|-----------------------|-------|----------|---------------------|-----------------------------------------------------|\n| `CODE_SUCCESS`        | `200` | `number` | **Ok**              | All sms: href values in anchors was updated         |\n| `CODE_NOT_FOUND`      | `404` | `number` | **Not found**       | Anchors with sms: href value doesn't exist          |\n| `CODE_UNSUPPORTED_OS` | `501` | `number` | **Not Implemented** | Current platform doesn't support sms: href protocol |\n\n---\n\n### fixValue\n\nSyntax:\n\n#### ``` async fixValue( smsValue: string [, encode: boolean ] ) : Promise\u003cstring\u003e ```\n\nUpdate input string value by current platform.\n\n|            | type              | default                            | description                                                         |\n|------------|-------------------|------------------------------------|---------------------------------------------------------------------|\n| `smsValue` | `string`          |                                    | Input string for update                                             |\n| [`encode`] | `boolean`         | Constructor `options.encode` value | Enable/disable message text encoding ( e.g., `encodeURIComponent` ) |\n| returns    | `Promise\u003cstring\u003e` |                                    | Valid SMS Href `sms:`anchor string                                  |\n\nExample:\n\n```typescript\nawait smsHref.fixValue('1234@body=Your message');\n// Android  --\u003e sms:1234?body=Your%20message\n// IOS \u003c= 7 --\u003e sms:1234;body=Your%20message\n// IOS \u003e= 8 --\u003e sms:1234\u0026body=Your%20message\n```\n\nExample (with disabled message encoding):\n\n```typescript\nawait smsHref.fixValue('1234@body=Your message', false);\n// Android  --\u003e sms:1234?body=Your message\n// IOS \u003c= 7 --\u003e sms:1234;body=Your message\n// IOS \u003e= 8 --\u003e sms:1234\u0026body=Your message\n```\n\n---\n\n### create\n\nSyntax:\n\n#### ``` async create( smsConfiguration: SmsConfiguration [, encode: boolean] ) : Promise\u003cstring\u003e ```\n\nCreates `sms:` href string from phone number and sms message text.\n\n|                              | type                                                   | default                            | description                                                         |\n|------------------------------|--------------------------------------------------------|------------------------------------|---------------------------------------------------------------------|\n| `smsConfiguration`           | [`SmsConfiguration`](#smsconfiguration)                |                                    |                                                                     |\n| `smsConfiguration[.phone]`   | `string` `number`                                      |                                    | SMS Phone number                                                    |\n| `smsConfiguration[.message]` | `string`                                               |                                    | SMS message text                                                    |\n| [ `encode` ]                 | `boolean`                                              | Constructor `options.encode` value | Enable/disable message text encoding ( e.g., `encodeURIComponent` ) |\n| returns                      | `Promise\u003cstring\u003e` - Valid SMS Href `sms:`anchor string |                                    |                                                                     |\n| throws                       | `Promise.reject\u003cTypeError\u003e`                            |                                    | If `phone` and `message` are both not provided                      |\n\n**NOTES**:\n\n- Phone and message are both optional, but one of them must be provided.\n- Phone number format validation is not implemented. You should use own validation.\n- SMS message format validation is not implemented. You should use own validation.\n\nExample:\n\n```typescript\nawait smsHref.create({\n    phone: 1234,\n    message: 'Your message'\n});\n// Android  --\u003e sms:1234?body=Your%20message\n// IOS \u003c= 7 --\u003e sms:1234;body=Your%20message\n// IOS \u003e= 8 --\u003e sms:1234\u0026body=Your%20message\n```\n\nExample (with disabled message encoding):\n\n```typescript\nawait smsHref.create({\n    phone: 1234,\n    message: 'Your message'\n}, false);\n// Android  --\u003e sms:1234?body=Your message\n// IOS \u003c= 7 --\u003e sms:1234;body=Your message\n// IOS \u003e= 8 --\u003e sms:1234\u0026body=Your message\n```\n\n---\n\n---\n\n---\n\n## Types\n\n### ResultCode\n\n```typescript\ntype ResultCode = number;\n```\n\n### Options\n\n```typescript\ntype Options = {\n    allow?: Devices;\n    separator?: string | null;\n    encode?: boolean;\n}\n```\n\n### Devices\n\n```typescript\ntype Devices = {\n    mobile?: boolean;\n    tablet?: boolean;\n    facebook?: boolean;\n};\n```\n\n### SmsConfiguration\n\n```typescript\ntype SmsConfiguration = {\n    phone?: string | number;\n    message?: string;\n}\n```\n\n---\n\n---\n\n---\n\n## License\n\n[MIT](LICENSE) © [Dárius Bokor](https://www.weroro.sk/)\n\n---\n**References**\n\n- [The \"sms\" URI Scheme](https://www.rfc-editor.org/rfc/rfc5724#section-2)\n- [Apple IOS - SMS Links](https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/SMSLinks/SMSLinks.html)\n- [stackoverflow -\u003e 58131833](https://stackoverflow.com/a/58131833/2276415)\n- [stackoverflow -\u003e 19126326](https://stackoverflow.com/a/19126326/2276415)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweroro-sk%2Fsms-href","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweroro-sk%2Fsms-href","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweroro-sk%2Fsms-href/lists"}