-
Notifications
You must be signed in to change notification settings - Fork 188
SDK Go version #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK Go version #907
Changes from 11 commits
3ef30ed
34e0958
b89c8b7
a50bf52
ef849af
f29e574
823c33b
90e2dc6
644b2b6
19b287f
7c4618f
4e9d0aa
fcc42bb
da58e7d
e2a1d72
30d8a92
e0c5b1b
42f081a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,256 @@ | ||
| package common | ||
|
|
||
| type Country3LetterCode string | ||
|
|
||
| const ( | ||
| AFG Country3LetterCode = "AFG" // Afghanistan | ||
| ALA Country3LetterCode = "ALA" // Aland Islands | ||
| ALB Country3LetterCode = "ALB" // Albania | ||
| DZA Country3LetterCode = "DZA" // Algeria | ||
| ASM Country3LetterCode = "ASM" // American Samoa | ||
| AND Country3LetterCode = "AND" // Andorra | ||
| AGO Country3LetterCode = "AGO" // Angola | ||
| AIA Country3LetterCode = "AIA" // Anguilla | ||
| ATA Country3LetterCode = "ATA" // Antarctica | ||
| ATG Country3LetterCode = "ATG" // Antigua and Barbuda | ||
| ARG Country3LetterCode = "ARG" // Argentina | ||
| ARM Country3LetterCode = "ARM" // Armenia | ||
| ABW Country3LetterCode = "ABW" // Aruba | ||
| AUS Country3LetterCode = "AUS" // Australia | ||
| AUT Country3LetterCode = "AUT" // Austria | ||
| AZE Country3LetterCode = "AZE" // Azerbaijan | ||
| BHS Country3LetterCode = "BHS" // Bahamas | ||
| BHR Country3LetterCode = "BHR" // Bahrain | ||
| BGD Country3LetterCode = "BGD" // Bangladesh | ||
| BRB Country3LetterCode = "BRB" // Barbados | ||
| BLR Country3LetterCode = "BLR" // Belarus | ||
| BEL Country3LetterCode = "BEL" // Belgium | ||
| BLZ Country3LetterCode = "BLZ" // Belize | ||
| BEN Country3LetterCode = "BEN" // Benin | ||
| BMU Country3LetterCode = "BMU" // Bermuda | ||
| BTN Country3LetterCode = "BTN" // Bhutan | ||
| BOL Country3LetterCode = "BOL" // Bolivia (Plurinational State of) | ||
| BES Country3LetterCode = "BES" // Bonaire, Sint Eustatius and Saba | ||
| BIH Country3LetterCode = "BIH" // Bosnia and Herzegovina | ||
| BWA Country3LetterCode = "BWA" // Botswana | ||
| BVT Country3LetterCode = "BVT" // Bouvet Island | ||
| BRA Country3LetterCode = "BRA" // Brazil | ||
| IOT Country3LetterCode = "IOT" // British Indian Ocean Territory | ||
| BRN Country3LetterCode = "BRN" // Brunei Darussalam | ||
| BGR Country3LetterCode = "BGR" // Bulgaria | ||
| BFA Country3LetterCode = "BFA" // Burkina Faso | ||
| BDI Country3LetterCode = "BDI" // Burundi | ||
| CPV Country3LetterCode = "CPV" // Cabo Verde | ||
| KHM Country3LetterCode = "KHM" // Cambodia | ||
| CMR Country3LetterCode = "CMR" // Cameroon | ||
| CAN Country3LetterCode = "CAN" // Canada | ||
| CYM Country3LetterCode = "CYM" // Cayman Islands | ||
| CAF Country3LetterCode = "CAF" // Central African Republic | ||
| TCD Country3LetterCode = "TCD" // Chad | ||
| CHL Country3LetterCode = "CHL" // Chile | ||
| CHN Country3LetterCode = "CHN" // China | ||
| CXR Country3LetterCode = "CXR" // Christmas Island | ||
| CCK Country3LetterCode = "CCK" // Cocos (Keeling) Islands | ||
| COL Country3LetterCode = "COL" // Colombia | ||
| COM Country3LetterCode = "COM" // Comoros | ||
| COG Country3LetterCode = "COG" // Congo | ||
| COD Country3LetterCode = "COD" // Congo, Democratic Republic of the | ||
| COK Country3LetterCode = "COK" // Cook Islands | ||
| CRI Country3LetterCode = "CRI" // Costa Rica | ||
| CIV Country3LetterCode = "CIV" // Cote d'Ivoire | ||
| HRV Country3LetterCode = "HRV" // Croatia | ||
| CUB Country3LetterCode = "CUB" // Cuba | ||
| CUW Country3LetterCode = "CUW" // Curacao | ||
| CYP Country3LetterCode = "CYP" // Cyprus | ||
| CZE Country3LetterCode = "CZE" // Czechia | ||
| DNK Country3LetterCode = "DNK" // Denmark | ||
| DJI Country3LetterCode = "DJI" // Djibouti | ||
| DMA Country3LetterCode = "DMA" // Dominica | ||
| DOM Country3LetterCode = "DOM" // Dominican Republic | ||
| ECU Country3LetterCode = "ECU" // Ecuador | ||
| EGY Country3LetterCode = "EGY" // Egypt | ||
| SLV Country3LetterCode = "SLV" // El Salvador | ||
| GNQ Country3LetterCode = "GNQ" // Equatorial Guinea | ||
| ERI Country3LetterCode = "ERI" // Eritrea | ||
| EST Country3LetterCode = "EST" // Estonia | ||
| SWZ Country3LetterCode = "SWZ" // Eswatini | ||
| ETH Country3LetterCode = "ETH" // Ethiopia | ||
| FLK Country3LetterCode = "FLK" // Falkland Islands (Malvinas) | ||
| FRO Country3LetterCode = "FRO" // Faroe Islands | ||
| FJI Country3LetterCode = "FJI" // Fiji | ||
| FIN Country3LetterCode = "FIN" // Finland | ||
| FRA Country3LetterCode = "FRA" // France | ||
| GUF Country3LetterCode = "GUF" // French Guiana | ||
| PYF Country3LetterCode = "PYF" // French Polynesia | ||
| ATF Country3LetterCode = "ATF" // French Southern Territories | ||
| GAB Country3LetterCode = "GAB" // Gabon | ||
| GMB Country3LetterCode = "GMB" // Gambia | ||
| GEO Country3LetterCode = "GEO" // Georgia | ||
| DEU Country3LetterCode = "DEU" // Germany | ||
| D Country3LetterCode = "D<<" // Germany (Bundesrepublik Deutschland passport format) | ||
| GHA Country3LetterCode = "GHA" // Ghana | ||
| GIB Country3LetterCode = "GIB" // Gibraltar | ||
| GRC Country3LetterCode = "GRC" // Greece | ||
| GRL Country3LetterCode = "GRL" // Greenland | ||
| GRD Country3LetterCode = "GRD" // Grenada | ||
| GLP Country3LetterCode = "GLP" // Guadeloupe | ||
| GUM Country3LetterCode = "GUM" // Guam | ||
| GTM Country3LetterCode = "GTM" // Guatemala | ||
| GGY Country3LetterCode = "GGY" // Guernsey | ||
| GIN Country3LetterCode = "GIN" // Guinea | ||
| GNB Country3LetterCode = "GNB" // Guinea-Bissau | ||
| GUY Country3LetterCode = "GUY" // Guyana | ||
| HTI Country3LetterCode = "HTI" // Haiti | ||
| HMD Country3LetterCode = "HMD" // Heard Island and McDonald Islands | ||
| VAT Country3LetterCode = "VAT" // Holy See | ||
| HND Country3LetterCode = "HND" // Honduras | ||
| HKG Country3LetterCode = "HKG" // Hong Kong | ||
| HUN Country3LetterCode = "HUN" // Hungary | ||
| ISL Country3LetterCode = "ISL" // Iceland | ||
| IND Country3LetterCode = "IND" // India | ||
| IDN Country3LetterCode = "IDN" // Indonesia | ||
| IRN Country3LetterCode = "IRN" // Iran (Islamic Republic of) | ||
| IRQ Country3LetterCode = "IRQ" // Iraq | ||
| IRL Country3LetterCode = "IRL" // Ireland | ||
| IMN Country3LetterCode = "IMN" // Isle of Man | ||
| ISR Country3LetterCode = "ISR" // Israel | ||
| ITA Country3LetterCode = "ITA" // Italy | ||
| JAM Country3LetterCode = "JAM" // Jamaica | ||
| JPN Country3LetterCode = "JPN" // Japan | ||
| JEY Country3LetterCode = "JEY" // Jersey | ||
| JOR Country3LetterCode = "JOR" // Jordan | ||
| KAZ Country3LetterCode = "KAZ" // Kazakhstan | ||
| KEN Country3LetterCode = "KEN" // Kenya | ||
| KIR Country3LetterCode = "KIR" // Kiribati | ||
| PRK Country3LetterCode = "PRK" // Korea (Democratic People's Republic of) | ||
| KOR Country3LetterCode = "KOR" // Korea, Republic of | ||
| KWT Country3LetterCode = "KWT" // Kuwait | ||
| KGZ Country3LetterCode = "KGZ" // Kyrgyzstan | ||
| LAO Country3LetterCode = "LAO" // Lao People's Democratic Republic | ||
| LVA Country3LetterCode = "LVA" // Latvia | ||
| LBN Country3LetterCode = "LBN" // Lebanon | ||
| LSO Country3LetterCode = "LSO" // Lesotho | ||
| LBR Country3LetterCode = "LBR" // Liberia | ||
| LBY Country3LetterCode = "LBY" // Libya | ||
| LIE Country3LetterCode = "LIE" // Liechtenstein | ||
| LTU Country3LetterCode = "LTU" // Lithuania | ||
| LUX Country3LetterCode = "LUX" // Luxembourg | ||
| MAC Country3LetterCode = "MAC" // Macao | ||
| MDG Country3LetterCode = "MDG" // Madagascar | ||
| MWI Country3LetterCode = "MWI" // Malawi | ||
| MYS Country3LetterCode = "MYS" // Malaysia | ||
| MDV Country3LetterCode = "MDV" // Maldives | ||
| MLI Country3LetterCode = "MLI" // Mali | ||
| MLT Country3LetterCode = "MLT" // Malta | ||
| MHL Country3LetterCode = "MHL" // Marshall Islands | ||
| MTQ Country3LetterCode = "MTQ" // Martinique | ||
| MRT Country3LetterCode = "MRT" // Mauritania | ||
| MUS Country3LetterCode = "MUS" // Mauritius | ||
| MYT Country3LetterCode = "MYT" // Mayotte | ||
| MEX Country3LetterCode = "MEX" // Mexico | ||
| FSM Country3LetterCode = "FSM" // Micronesia (Federated States of) | ||
| MDA Country3LetterCode = "MDA" // Moldova, Republic of | ||
| MCO Country3LetterCode = "MCO" // Monaco | ||
| MNG Country3LetterCode = "MNG" // Mongolia | ||
| MNE Country3LetterCode = "MNE" // Montenegro | ||
| MSR Country3LetterCode = "MSR" // Montserrat | ||
| MAR Country3LetterCode = "MAR" // Morocco | ||
| MOZ Country3LetterCode = "MOZ" // Mozambique | ||
| MMR Country3LetterCode = "MMR" // Myanmar | ||
| NAM Country3LetterCode = "NAM" // Namibia | ||
| NRU Country3LetterCode = "NRU" // Nauru | ||
| NPL Country3LetterCode = "NPL" // Nepal | ||
| NLD Country3LetterCode = "NLD" // Netherlands | ||
| NCL Country3LetterCode = "NCL" // New Caledonia | ||
| NZL Country3LetterCode = "NZL" // New Zealand | ||
| NIC Country3LetterCode = "NIC" // Nicaragua | ||
| NER Country3LetterCode = "NER" // Niger | ||
| NGA Country3LetterCode = "NGA" // Nigeria | ||
| NIU Country3LetterCode = "NIU" // Niue | ||
| NFK Country3LetterCode = "NFK" // Norfolk Island | ||
| MKD Country3LetterCode = "MKD" // North Macedonia | ||
| MNP Country3LetterCode = "MNP" // Northern Mariana Islands | ||
| NOR Country3LetterCode = "NOR" // Norway | ||
| OMN Country3LetterCode = "OMN" // Oman | ||
| PAK Country3LetterCode = "PAK" // Pakistan | ||
| PLW Country3LetterCode = "PLW" // Palau | ||
| PSE Country3LetterCode = "PSE" // Palestine, State of | ||
| PAN Country3LetterCode = "PAN" // Panama | ||
| PNG Country3LetterCode = "PNG" // Papua New Guinea | ||
| PRY Country3LetterCode = "PRY" // Paraguay | ||
| PER Country3LetterCode = "PER" // Peru | ||
| PHL Country3LetterCode = "PHL" // Philippines | ||
| PCN Country3LetterCode = "PCN" // Pitcairn | ||
| POL Country3LetterCode = "POL" // Poland | ||
| PRT Country3LetterCode = "PRT" // Portugal | ||
| PRI Country3LetterCode = "PRI" // Puerto Rico | ||
| QAT Country3LetterCode = "QAT" // Qatar | ||
| REU Country3LetterCode = "REU" // Reunion | ||
| ROU Country3LetterCode = "ROU" // Romania | ||
| RUS Country3LetterCode = "RUS" // Russian Federation | ||
| RWA Country3LetterCode = "RWA" // Rwanda | ||
| BLM Country3LetterCode = "BLM" // Saint Barthelemy | ||
| SHN Country3LetterCode = "SHN" // Saint Helena, Ascension and Tristan da Cunha | ||
| KNA Country3LetterCode = "KNA" // Saint Kitts and Nevis | ||
| LCA Country3LetterCode = "LCA" // Saint Lucia | ||
| MAF Country3LetterCode = "MAF" // Saint Martin (French part) | ||
| SPM Country3LetterCode = "SPM" // Saint Pierre and Miquelon | ||
| VCT Country3LetterCode = "VCT" // Saint Vincent and the Grenadines | ||
| WSM Country3LetterCode = "WSM" // Samoa | ||
| SMR Country3LetterCode = "SMR" // San Marino | ||
| STP Country3LetterCode = "STP" // Sao Tome and Principe | ||
| SAU Country3LetterCode = "SAU" // Saudi Arabia | ||
| SEN Country3LetterCode = "SEN" // Senegal | ||
| SRB Country3LetterCode = "SRB" // Serbia | ||
| SYC Country3LetterCode = "SYC" // Seychelles | ||
| SLE Country3LetterCode = "SLE" // Sierra Leone | ||
| SGP Country3LetterCode = "SGP" // Singapore | ||
| SXM Country3LetterCode = "SXM" // Sint Maarten (Dutch part) | ||
| SVK Country3LetterCode = "SVK" // Slovakia | ||
| SVN Country3LetterCode = "SVN" // Slovenia | ||
| SLB Country3LetterCode = "SLB" // Solomon Islands | ||
| SOM Country3LetterCode = "SOM" // Somalia | ||
| ZAF Country3LetterCode = "ZAF" // South Africa | ||
| SGS Country3LetterCode = "SGS" // South Georgia and the South Sandwich Islands | ||
| SSD Country3LetterCode = "SSD" // South Sudan | ||
| ESP Country3LetterCode = "ESP" // Spain | ||
| LKA Country3LetterCode = "LKA" // Sri Lanka | ||
| SDN Country3LetterCode = "SDN" // Sudan | ||
| SUR Country3LetterCode = "SUR" // Suriname | ||
| SJM Country3LetterCode = "SJM" // Svalbard and Jan Mayen | ||
| SWE Country3LetterCode = "SWE" // Sweden | ||
| CHE Country3LetterCode = "CHE" // Switzerland | ||
| SYR Country3LetterCode = "SYR" // Syrian Arab Republic | ||
| TWN Country3LetterCode = "TWN" // Taiwan, Province of China | ||
| TJK Country3LetterCode = "TJK" // Tajikistan | ||
| TZA Country3LetterCode = "TZA" // Tanzania, United Republic of | ||
| THA Country3LetterCode = "THA" // Thailand | ||
| TLS Country3LetterCode = "TLS" // Timor-Leste | ||
| TGO Country3LetterCode = "TGO" // Togo | ||
| TKL Country3LetterCode = "TKL" // Tokelau | ||
| TON Country3LetterCode = "TON" // Tonga | ||
| TTO Country3LetterCode = "TTO" // Trinidad and Tobago | ||
| TUN Country3LetterCode = "TUN" // Tunisia | ||
| TUR Country3LetterCode = "TUR" // Turkey | ||
| TKM Country3LetterCode = "TKM" // Turkmenistan | ||
| TCA Country3LetterCode = "TCA" // Turks and Caicos Islands | ||
| TUV Country3LetterCode = "TUV" // Tuvalu | ||
| UGA Country3LetterCode = "UGA" // Uganda | ||
| UKR Country3LetterCode = "UKR" // Ukraine | ||
| ARE Country3LetterCode = "ARE" // United Arab Emirates | ||
| GBR Country3LetterCode = "GBR" // United Kingdom of Great Britain and Northern Ireland | ||
| USA Country3LetterCode = "USA" // United States of America | ||
| UMI Country3LetterCode = "UMI" // United States Minor Outlying Islands | ||
| URY Country3LetterCode = "URY" // Uruguay | ||
| UZB Country3LetterCode = "UZB" // Uzbekistan | ||
| VUT Country3LetterCode = "VUT" // Vanuatu | ||
| VEN Country3LetterCode = "VEN" // Venezuela (Bolivarian Republic of) | ||
| VNM Country3LetterCode = "VNM" // Viet Nam | ||
| VGB Country3LetterCode = "VGB" // Virgin Islands (British) | ||
| VIR Country3LetterCode = "VIR" // Virgin Islands (U.S.) | ||
| WLF Country3LetterCode = "WLF" // Wallis and Futuna | ||
| ESH Country3LetterCode = "ESH" // Western Sahara | ||
| YEM Country3LetterCode = "YEM" // Yemen | ||
| ZMB Country3LetterCode = "ZMB" // Zambia | ||
| ZWE Country3LetterCode = "ZWE" // Zimbabwe | ||
| ) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,122 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "math/big" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "regexp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "strings" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/iden3/go-iden3-crypto/poseidon" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func FlexiblePoseidon(inputs []*big.Int) (*big.Int, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(inputs) == 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("no inputs provided") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(inputs) > 16 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function flexiblePoseidon(inputs: bigint[]): bigint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tru tru , will change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use url.Parse for robust endpoint normalization (remove ports, handle case-insensitive schemes), and align behavior with comment
The current regex-based approach:
- Misses uppercase schemes (e.g., HTTPS://).
- Retains ports despite the comment saying “domain”.
- Doesn’t trim spaces or handle odd inputs as reliably as url.Parse.
Refactor to use net/url and trim whitespace. This also removes the need for regexp here.
Apply this diff:
-import (
- "fmt"
- "math/big"
- "regexp"
- "strings"
-
- "github.com/iden3/go-iden3-crypto/poseidon"
-)
+import (
+ "fmt"
+ "math/big"
+ "net/url"
+ "strings"
+
+ "github.com/iden3/go-iden3-crypto/poseidon"
+)-// FormatEndpoint removes protocol and path from URL, keeping only the domain
+// FormatEndpoint removes protocol and path from URL, keeping only the domain (without port)
func FormatEndpoint(endpoint string) string {
- if endpoint == "" {
- return ""
- }
-
- // Remove protocol (http:// or https://)
- re := regexp.MustCompile(`^https?://`)
- formatted := re.ReplaceAllString(endpoint, "")
-
- // Split by '/' and take only the first part (domain)
- parts := strings.Split(formatted, "/")
- return parts[0]
+ s := strings.TrimSpace(endpoint)
+ if s == "" {
+ return ""
+ }
+ // Ensure a scheme for proper parsing when the input is a bare host
+ if !strings.Contains(s, "://") {
+ s = "https://" + s
+ }
+ u, err := url.Parse(s)
+ if err != nil {
+ return ""
+ }
+ // Hostname strips the port if present
+ return u.Hostname()
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func FormatEndpoint(endpoint string) string { | |
| if endpoint == "" { | |
| return "" | |
| } | |
| // Remove protocol (http:// or https://) | |
| re := regexp.MustCompile(`^https?://`) | |
| formatted := re.ReplaceAllString(endpoint, "") | |
| // Split by '/' and take only the first part (domain) | |
| parts := strings.Split(formatted, "/") | |
| return parts[0] | |
| } | |
| import ( | |
| "fmt" | |
| "math/big" | |
| "net/url" | |
| "strings" | |
| "github.com/iden3/go-iden3-crypto/poseidon" | |
| ) | |
| // FormatEndpoint removes protocol and path from URL, keeping only the domain (without port) | |
| func FormatEndpoint(endpoint string) string { | |
| s := strings.TrimSpace(endpoint) | |
| if s == "" { | |
| return "" | |
| } | |
| // Ensure a scheme for proper parsing when the input is a bare host | |
| if !strings.Contains(s, "://") { | |
| s = "https://" + s | |
| } | |
| u, err := url.Parse(s) | |
| if err != nil { | |
| return "" | |
| } | |
| // Hostname strips the port if present | |
| return u.Hostname() | |
| } |
🤖 Prompt for AI Agents
In sdk/sdk-go/common/customHash.go around lines 59-71: the current regex-based
FormatEndpoint fails on uppercase schemes, leaves ports, and doesn't trim
spaces; replace it to trim whitespace, ensure a scheme exists (if missing,
prepend "http://"), parse with net/url.Parse, and return the hostname via
URL.Hostname() to drop ports; on parse error fall back to taking the trimmed
string before the first '/' and stripping any ":port" suffix; remove the regexp
usage and update imports accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Remove anomalous non-ISO code
D = "D<<"to prevent misuse and confusionThis exported constant deviates from ISO 3166-1 alpha-3 (three uppercase letters), introduces ambiguous naming, and could leak into UI/templating paths where angle brackets become problematic. If MRZ-specific tokens are needed, model them with a separate type in a dedicated MRZ module rather than mixing them into ISO country codes.
Apply this diff to remove the invalid constant:
- D Country3LetterCode = "D<<" // Germany (Bundesrepublik Deutschland passport format)To proactively catch similar issues project-wide, you can verify no usages exist:
🏁 Script executed:
Length of output: 702
Remove anomalous non‑ISO constant
D = "D<<"from sdk/sdk-go/common/constants.goThis constant is not a valid ISO 3166‑1 alpha‑3 code (it's an MRZ token) and should not live in the exported Country3LetterCode set — it risks confusion and templating/escaping issues.
Findings
D Country3LetterCode = "D<<"(only occurrence found)."D<<"orcommon.Dwere found.Apply this removal diff:
- D Country3LetterCode = "D<<" // Germany (Bundesrepublik Deutschland passport format)Recommended fixes (pick one)
Quick note: since no references were found, removing or relocating this constant is a low‑risk, high‑clarity fix.
📝 Committable suggestion
🤖 Prompt for AI Agents