Skip to content

Commit 69ca46c

Browse files
Merge pull request #40 from NaverPayDev/feature/39
2 parents 799a6cb + 1047b48 commit 69ca46c

File tree

6 files changed

+493
-37
lines changed

6 files changed

+493
-37
lines changed

.changeset/small-oranges-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@naverpay/nurl": patch
3+
---
4+
5+
🚚 punycode 를 내재화합니다.

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
"url": "https://github.com/NaverPayDev/nurl.git"
4848
},
4949
"license": "MIT",
50-
"dependencies": {
51-
"@babel/runtime-corejs3": "^7.25.6",
52-
"npm-punycode": "npm:punycode@^2.3.1"
53-
},
5450
"devDependencies": {
5551
"@babel/plugin-transform-runtime": "^7.25.4",
5652
"@babel/preset-env": "^7.25.4",
@@ -62,7 +58,7 @@
6258
"@naverpay/markdown-lint": "^0.0.3",
6359
"@naverpay/prettier-config": "^1.0.0",
6460
"@rollup/plugin-babel": "^6.0.4",
65-
"@types/npm-punycode": "npm:@types/punycode@^2.1.4",
61+
"babel-plugin-polyfill-corejs3": "^0.11.0",
6662
"browserslist-to-esbuild": "^2.1.1",
6763
"tsup": "^8.2.4",
6864
"typescript": "^5.5.4",

pnpm-lock.yaml

Lines changed: 88 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nurl.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
/**
2-
* Note: We use 'npm-punycode' alias instead of 'punycode/' to properly support dual packages in ESM.
3-
* This ensures that this third-party module is used instead of the built-in
4-
* Node.js 'punycode' module, which has been deprecated since Node.js v7.0.0.
5-
* @see https://github.com/mathiasbynens/punycode.js#installation
6-
* @see https://nodejs.org/api/punycode.html for deprecation info
7-
*/
8-
import punycode from 'npm-punycode'
9-
1+
import {decode, encode} from './punycode'
102
import {
113
extractPathKey,
124
getDynamicPaths,
@@ -364,7 +356,7 @@ export default class NURL implements URL {
364356
.map((segment) => {
365357
for (const char of segment) {
366358
if (isASCIICodeChar(char)) {
367-
return `${this.punycodePrefix}${punycode.encode(segment)}`
359+
return `${this.punycodePrefix}${encode(segment)}`
368360
}
369361
}
370362
return segment
@@ -376,7 +368,7 @@ export default class NURL implements URL {
376368
let href = this._href
377369

378370
this._hostname.split('.').forEach((segment) => {
379-
href = href.replace(segment, punycode.decode(segment.replace(this.punycodePrefix, '')))
371+
href = href.replace(segment, decode(segment.replace(this.punycodePrefix, '')))
380372
})
381373

382374
return href
@@ -385,7 +377,7 @@ export default class NURL implements URL {
385377
get decodedHostname(): string {
386378
return this._hostname
387379
.split('.')
388-
.map((segment) => punycode.decode(segment.replace(this.punycodePrefix, '')))
380+
.map((segment) => decode(segment.replace(this.punycodePrefix, '')))
389381
.join('.')
390382
}
391383
}

0 commit comments

Comments
 (0)