unpkg/packages/unpkg/modules/utils/parseBareModuleIdentifier.js

13 lines
277 B
JavaScript
Raw Normal View History

2017-11-25 21:10:52 +00:00
const bareModuleIdentifierFormat = /^((?:@[^\/]+\/)?[^\/]+)(\/.*)?$/
function parseBareModuleIdentifier(id) {
const match = bareModuleIdentifierFormat.exec(id)
return {
packageName: match[1],
2017-11-25 21:25:01 +00:00
file: match[2] || ""
2017-11-25 21:10:52 +00:00
}
}
module.exports = parseBareModuleIdentifier